Panadas - sum of each column based on group by first column
I have this text file which has Table and other 3 other columns indicating Select, Update and Insert. I would like to do group by table and sum of each column and grand total at the end.
df=data.groupby(['Table'])
print df.groupby(['Table'])["Select","Update","Insert"].agg('sum')
Text file has data in this format
Table Select Update Insert
A 10 8 5
B 12 2 0
C 10 2 4
B 19 3 1
D 13 0 5
A 11 7 3
Expected output
Table Select Update Insert
A 21 15 8
B 31 5 1
C 10 2 4
D 13 0 5
Total 75 22 18
df.groupby with sum isn't aggregating data properly for every column. If aggregation is done only on one column then it is good but output on my terminal is all messed up.
Appreciate your help!