Category: pandas

Problem

Create pivot tables from DataFrames.

Solution

  pivot = df.pivot_table(values="sales", index="month", columns="region", aggfunc="sum")
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path