04-07: Sales Dashboard (Pandas + Matplotlib)¶
Merges a sales table with a products table using pd.merge(). Computes monthly revenue trends, category breakdowns, regional distribution, and top products. Generates a 4-panel dashboard chart saved as sales_dashboard.png.
Topics covered: pd.merge() · df.groupby().agg() · named aggregation · df.reindex() · vectorised Revenue = Qty × Cost · plt.subplots(2,2) · pie chart · line chart with fill
Difficulty: ⭐⭐⭐ Intermediate–Advanced
Requirements¶
How to Run¶
Dashboard Panels¶
| Panel | Chart Type | Shows |
|---|---|---|
| Top-left | Line + fill | Monthly revenue trend |
| Top-right | Horizontal bar | Revenue by category |
| Bottom-left | Pie | Revenue share by region |
| Bottom-right | Vertical bar | Top 5 products |
Key Concepts Practised¶
| Concept | Where used |
|---|---|
pd.merge(sales, products, on="ProductID") |
SQL-style JOIN |
df["Quantity"] * df["UnitCost"] |
Vectorised revenue |
groupby().agg(Revenue=(...), Units=(...)) |
Named aggregation |
monthly.reindex(MONTHS_ORDER) |
Custom sort order |
groupby().idxmax() / .head(n) |
Top products |