How to insert a sum row of groupby sums
after the groupby use df.reset_index() to convert the df to a dataframe again
I am trying to insert a new row of totals after groupby sum.
I can get the groupby sums of my table. I can also compute the sum of groupby sums with a second groupby sum. I tried and searched here to find a solution to insert/append each sum of sums as a new row (e.g. named Total) after each group, but to no avail.
First groupby sum
df.groupby(['Col1', 'Col2']).sum()
Second groupby sum
df.groupby(['Col1', 'Col2']).sum().groupby(level=[0]).sum()