A dashboard is several charts answering several questions about the same data, on one figure, with one consistent look. The pieces are all things you have built: a time series, a ranked bar chart, a histogram. The work is in the joining: aggregating the data for each panel (the line wants monthly totals, the bars want per-region totals, the histogram wants the raw order values), labelling every axis so each panel stands alone, and putting a title over the whole figure.
This question builds a three-panel sales dashboard from one table of orders, and because every panel is built from matplotlib objects you can check each one against the aggregation it should show.
Implement sales_dashboard(df). The signature and docstring are already in the editor.
df has the columns date (datetime), region (text) and amount (number), with at least one row.fig, a figure with exactly three Axes in one row (plt.subplots(1, 3)), in this order: revenue by month, revenue by region, order amounts.amount per calendar month, in chronological order, with the title "Revenue by month", x label "Month" and y label "Revenue".amount per region, largest total first (ties by region name ascending), bars centred at 0..n-1 with the region names as tick labels, title "Revenue by region", x label "Region", y label "Revenue".amount values with 5 bins, title "Order amounts", x label "Amount", y label "Orders".suptitle) "Sales dashboard". Do not call plt.show().Aggregate with pandas first (groupby), then draw. df["date"].dt.to_period("M") gives a calendar month to group by.
Draw each panel on its own Axes from the array that plt.subplots(1, 3) returns.
Sort the region totals with sort_values(ascending=False, kind="mergesort") after sorting by name, so ties come out in name order.
No results yet
Run your code to check it against the examples, or submit to run every test.