1df.groupby(['col1','col2']).agg({'col3':'sum','col4':'sum'}).reset_index()
2
1#UPDATED (June 2020): Introduced in Pandas 0.25.0,
2#Pandas has added new groupby behavior “named aggregation” and tuples,
3#for naming the output columns when applying multiple aggregation functions
4#to specific columns.
5
6df.groupby(
7 ['col1','col2']
8 ).agg(
9 sum_col3 = ('col3','sum'),
10 sum_col4 = ('col4','sum'),
11 ).reset_index()
12