我有这个df
'Item' 'Units Sold'
Item1 1
Item2 3
Item3 10
Item1 2
Item3 4
然后,我想按项目分组并汇总已售出的单位:
Item
'Item' 'Units Sold'
Item1 3
Item2 3
Item3 14
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句