I have pandas.Dataframe df
| A | B | C | D |
|---|---|---|---|
| 1 | 2 | 3 | 4 |
| 1 | 2 | 5 | 6 |
| 5 | 5 | 7 | 8 |
| 5 | 6 | 9 | 0 |
| 5 | 6 | 1 | 1 |
and I want to group it by 2 first columns (A and B), get the sum of the rows and get the following df_summed_by_groups
| A | B | C | D |
|---|---|---|---|
| 1 | 2 | 8 | 10 |
| 5 | 5 | 7 | 8 |
| 5 | 6 | 10 | 1 |
If I use
df.groupby(['A', 'B']).sum()
I get a Series with multiple index which cannot be transformed to the dataframe I need as soon as I understand