Spaces:
Sleeping
Sleeping
Download tools/plot_generator.py from mgbam/BizIntel_AI: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/mgbam/BizIntel_AI/resolve/773f0cfdfef56f3cebc157dd3065acdd3c40fa45/tools/plot_generator.py
- Command line
-
hf download hf://spaces/mgbam/BizIntel_AI@773f0cfdfef56f3cebc157dd3065acdd3c40fa45/tools/plot_generator.py
-
curl -L -o plot_generator.py https://huggingface.co/spaces/mgbam/BizIntel_AI/resolve/773f0cfdfef56f3cebc157dd3065acdd3c40fa45/tools/plot_generator.py
752 Bytes
| import pandas as pd | |
| import plotly.graph_objects as go | |
| def plot_sales_tool(file_path: str, date_col: str = "Month") -> str: | |
| """ | |
| Builds an interactive Plotly line chart for Sales. | |
| Saves a PNG fallback (sales_plot.png) for Streamlit thumbnail. | |
| """ | |
| df = pd.read_csv(file_path) | |
| if date_col not in df.columns or "Sales" not in df.columns: | |
| return f"❌ '{date_col}' or 'Sales' column missing." | |
| fig = go.Figure( | |
| go.Scatter( | |
| x=df[date_col], | |
| y=df["Sales"], | |
| mode="lines+markers", | |
| line=dict(width=2), | |
| ) | |
| ) | |
| fig.update_layout(title="Sales Trend", template="plotly_dark") | |
| fig.write_image("sales_plot.png") # still save for PNG fallback | |
| return fig | |