我试图在pandas数据框中总结唯一值的总和,但由于某种原因,我很难为每个唯一值获取一个数字。
A B C D
calmuni 30,000.00 CA 1-3 year paper
calmuni 95,000.00 CA 1-3 year paper
massmuni 25,000.00 MA 1-3 year paper
massmuni 30,000.00 RI 1-3 year paper
massmuni 175,000.00 MA 1-3 year paper
我正在尝试根据A列中的唯一值对B列求和,但我的groupby函数不起作用。我想为每个唯一值提供一个项目总和值:
orders.groupby('A')['B'].sum()
A
calmuni 30,000.0095,000.00125,000.0020,000.0020,000.00...
massmuni 25,000.0030,000.00175,000.0025,000.0050,000.00..