This should be an easy one, but somehow I couldn\'t find a solution that works.
I have a pandas dataframe which looks like this:
index col1 col2
The above answer didn't work for me.
df_new = df.groupby(['col1', 'col2']).sum()[["col3", "col4"]]
I was grouping by single group by and sum columns.
Here is the one worked for me.
D1.groupby(['col1'])['col2'].sum() << The sum at the end not the middle.