Problem Statement
How do you compute multiple aggregations per column with groupby?
Explanation
.agg accepts a list of functions per column or a dict mapping columns to functions. It creates a tidy summary in one pass.
This is faster and clearer than manual apply loops for standard aggregations.
Code Solution
SolutionRead Only
df.groupby('city').agg({'sales':['sum','mean'],'id':'count'})Practice Sets
This question appears in the following practice sets:
