1df.groupby(['col1','col2']).agg({'col3':'sum','col4':'sum'}).reset_index()
2
1grouped_multiple = df.groupby(['Team', 'Pos']).agg({'Age': ['mean', 'min', 'max']})
2grouped_multiple.columns = ['age_mean', 'age_min', 'age_max']
3grouped_multiple = grouped_multiple.reset_index()
4print(grouped_multiple)
5
1In [8]: grouped = df.groupby('A')
2
3In [9]: grouped = df.groupby(['A', 'B'])
4
1In [11]: df.groupby(['col5', 'col2']).size()
2Out[11]:
3col5 col2
41 A 1
5 D 3
62 B 2
73 A 3
8 C 1
94 B 1
105 B 2
116 B 1
12dtype: int64
13