WeCodeAcademy

Pivot Tables

A pivot table reshapes a long list into a grid: one set of values down the side (index), another across the top (columns), and a summary in each cell (aggfunc). It is the Pandas version of the Excel PivotTable and is the fastest way to compare groups side by side.

Examplepython
Open in editor »
Quick check

In `pd.pivot_table`, what does `index` set?

Your turn: write the code

Make a pivot table of average units per product (index='product') and print it.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.