Skip to content
skillbld
Day 9 of 14 30 minpivot_table()melt()crosstab()

Switch tables between long and wide formats. Build summary grids with pivot_table(), turn wide spreadsheets into tidy long data with melt(), count combinations with crosstab(), and know when to use each.

By the end of today you can

  • Explain long (tidy) and wide data, and when each is useful
  • Summarise data into a grid with pivot_table(), including totals and missing cells
  • Turn wide data into long data with melt()
  • Count combinations of two categories with crosstab(), as counts or percentages
  • Choose between pivot_table() and pivot()

What's inside

  • 5 sections
  • 3 diagrams and mind maps
  • 6 code examples you can run
  • 5-question quiz
  1. 1Long and wide
  2. 2pivot_table(): long to a summary grid
  3. 3melt(): wide to long
  4. 4crosstab(): count combinations
  5. 5Which one do I need?

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free
Day 9: Reshaping Data · Data Analysis with pandas · SkillBld