Pivot Tables in pandas

easy
Unit 4 · Pandas I0/3 to milestone

Sales data arrives in long format: one row per sale with region, month and revenue. Build the report managers actually read.

Implement revenue_pivot(df) returning a DataFrame with regions as rows and months as columns (both sorted), holding total revenue, with missing combinations filled with 0. Add a "Total" column (row sums) and a "Total" row (column sums, including the grand total). Values should be floats.

Then implement top_month_per_region(df): a dict from region to the month with its highest revenue (ties: earliest month).

#pandas#pivot#reporting2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Pivot Tables in pandas · TechGradify