Skip to main content

Summarizing data with a pivot table

A pivot table is a data analysis tool that enables you to summarize, reorganize, and explore large datasets. It aggregates data, rotates perspectives, and filters, sorts, and groups information into meaningful categories.

Key benefits

  • Simplify Complex Data — Break down large datasets into manageable summaries
  • Identify Trends — Reveal patterns not immediately obvious in raw data
  • Flexible Analysis — Quickly change layout and structure to answer different questions
  • Efficiency — Automate data analysis for faster, regular reporting

Pandas pivot table syntax

Practical example: analyzing odd lots in AAPL trades

This example demonstrates analyzing AAPL trade data by:
  1. Extracting trades between 9:30 AM and 4 PM
  2. Creating an odd_lots boolean column (shares < 100)
  3. Extracting hour from timestamp
  4. Pivoting to count shares by hour and lot size
  5. Calculating percentage of odd lots per hour

Parameter reference