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

All grouping and combining commands · pandas and NumPy 3 cheatsheet

Was this page helpful?