Study
Pandas · pivot_table
Reshaping between long and wide formats with pivot_table, melt and crosstab, including margins and fill_value.
- pivot_table is groupby plus reshaping: index becomes rows, columns becomes columns, values get aggregated.
- melt is the inverse: it turns wide columns back into long rows.