Pivot Tables
Pivot tables reshape data to create summary tables with rows and columns from your data values.
Basic Pivot Table
Create a summary table:
Loading Pandas Playground...
Aggregation Functions
Specify how to aggregate values:
Loading Pandas Playground...
Multiple Values
Pivot multiple columns:
Loading Pandas Playground...
Adding Totals
Include row and column totals:
Loading Pandas Playground...
Handling Missing Values
Fill or handle NaN in pivots:
Loading Pandas Playground...
Multiple Index Levels
Create hierarchical pivots:
Loading Pandas Playground...
Exercise: Sales Pivot
Loading Exercise...
Exercise: Pivot with Totals
Loading Exercise...
Key Points
pivot_table()creates summary tablesindex=for row labels,columns=for column headersvalues=specifies data to aggregateaggfunc=sets aggregation (default is 'mean')margins=Trueadds row/column totalsfill_value=replaces NaN
Up next · Lesson 22 of 42
Cross Tabulation
1 min read
21 of 42 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

