On this page
article
GroupBy Aggregate
Summarize data by category with groupby.
Category: pandas
Problem
Summarize data by category with groupby.
Solution
summary = df.groupby("region")["sales"].agg(["sum", "mean", "count"])
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path