pivot_table for Cross-Tabs
Summarizing across two dimensions.
From Long Rows to a Grid
When you want a category-by-category summary, pivot_table turns tidy long rows into a clean two-dimensional grid. 🔄
The Three Key Arguments
Every pivot table needs three roles: which column becomes index, which becomes columns, and which values fill the cells.
df.pivot_table(index='region',
columns='month',
values='sales')All lessons in this course
- Wide vs Long, and Tidy Data
- pivot_table for Cross-Tabs
- melt to Go Long
- stack, unstack, and MultiIndex