pandas and NumPy 3 · Grouping and combining
Group and aggregate
Compute several statistics per group with named results.
df.groupby("country").agg(users=("id", "count"), avg_age=("age", "mean"))
Official pandas and NumPy 3 documentation
More grouping and combining commands
- Create a pivot table
- Join two DataFrames
- Stack DataFrames
- Compute a moving average
- Aggregate by time period
- Save to a CSV file
All grouping and combining commands · pandas and NumPy 3 cheatsheet