I have this df
'Item' 'Units Sold'
Item1 1
Item2 3
Item3 10
Item1 2
Item3 4
Then I want to group by item and sum the sold units:
Item
'Item' 'Units Sold'
Item1 3
Item2 3
Item3 14
I have this df
'Item' 'Units Sold'
Item1 1
Item2 3
Item3 10
Item1 2
Item3 4
Then I want to group by item and sum the sold units:
Item
'Item' 'Units Sold'
Item1 3
Item2 3
Item3 14
Use Groupby.sum()
:
In [1167]: df = df.groupby('Item', as_index=False).sum()
In [1168]: df
Out[1168]:
Item Units_Sold
0 Item1 3
1 Item2 3
2 Item3 14