pandas group by and then add sum column code example
Example 1: pandas groupby sum
df.groupby(['att1', 'att2']).agg({'att1': "count", 'att3': "sum",'att4': 'mean'})
Example 2: python groupby sum single columns
df.groupby(['A','C'], as_index=False)['B'].sum()