Python
#32

Build Matrix Dashboards with pivot_table in Pandas

MediumFlipkart
Interview Question #32
Asked at Flipkart

Given sales records with `region`, `category`, and `sales`, create a pivot table showing total sales across regions (rows) and categories (columns), including Grand Total margins.

Input Table: sales
3 rows preview
regioncategorysales
NorthElectronics1000
NorthFashion500
SouthElectronics1200
Expected Output Structure3 rows
regionElectronicsFashionAll
North10005001500
South120001200
All22005002700
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us