# Pivot Tables and crosstab

pivot_table turns a summary of two columns into a grid, one value down the side (index) and one across the top (columns), with the cells worked out from values by aggfunc; fill_value puts 0 in an empty cell, margins adds the totals, and crosstab counts every combination of two columns, as row percentages with normalize='index'.

![Cheat sheet: Pivot Tables and crosstab](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/a426394f25bb4039b2739ab59391e4f4.webp)

- Category: Data Analysis
- Level: Journeyman
- Tags: crosstab(), Pivot Table, python
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/pandas-pivot-table-cheat-sheet
