Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,22 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import matplotlib.pyplot as plt
|
| 4 |
|
| 5 |
CSV_URL = "https://gardenstatemls.stats.showingtime.com/infoserv/s-v1/kpou-Asg"
|
| 6 |
|
| 7 |
-
|
| 8 |
-
def plot_csv():
|
| 9 |
-
# Read CSV directly from URL
|
| 10 |
-
df = pd.read_csv(CSV_URL)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
plt.title("CSV Data Plot")
|
| 16 |
-
plt.xlabel(df.columns[0])
|
| 17 |
-
plt.ylabel("Values")
|
| 18 |
-
plt.grid(True)
|
| 19 |
-
plt.tight_layout()
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
demo = gr.Interface(
|
| 29 |
-
fn=plot_csv,
|
| 30 |
-
inputs=[],
|
| 31 |
-
outputs=gr.Image(type="filepath"),
|
| 32 |
-
title="CSV Plotter",
|
| 33 |
-
description="This Space downloads the CSV from GSMLS"
|
| 34 |
-
)
|
| 35 |
|
| 36 |
demo.launch(debug=True)
|
|
|
|
| 1 |
+
import gradio as gr import pandas as pd import plotly.express as px import plotly.graph_objects as go
|
|
|
|
|
|
|
| 2 |
|
| 3 |
CSV_URL = "https://gardenstatemls.stats.showingtime.com/infoserv/s-v1/kpou-Asg"
|
| 4 |
|
| 5 |
+
def plot_csv(area): df = pd.read_csv(CSV_URL) fig = go.Figure()
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Add full data traces
|
| 8 |
+
for col in df.columns[1:]:
|
| 9 |
+
fig.add_trace(go.Scatter(x=df[df.columns[0]], y=df[col], mode='lines', name=col))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Add filtered trace if area is specified
|
| 12 |
+
if area and 'Area' in df.columns:
|
| 13 |
+
filtered_df = df[df['Area'].str.contains(area, case=False, na=False)]
|
| 14 |
+
for col in filtered_df.columns[1:]:
|
| 15 |
+
fig.add_trace(go.Scatter(x=filtered_df[filtered_df.columns[0]], y=filtered_df[col], mode='lines+markers', name=f"Filtered: {col} ({area})"))
|
| 16 |
|
| 17 |
+
fig.update_layout(title="Full CSV Data Plot with Area Filter Overlay")
|
| 18 |
+
return fig
|
| 19 |
|
| 20 |
+
with gr.Blocks() as demo: gr.Markdown("## Interactive CSV Plotter (Full Plot + Area Filter Overlay)") area_input = gr.Textbox(label="Filter Area", placeholder="Enter area name to highlight") plot_output = gr.Plot() run_button = gr.Button("Plot") run_button.click(plot_csv, inputs=area_input, outputs=plot_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
demo.launch(debug=True)
|