嗨,我有两个熊猫系列
series1
Company Product Price
ABC Apple 1234
Orange 123
BCD Apple 123
PCT Pineapple 434
Beef 884
series2
Company Product Price
BCD Orange 751
PCT Pineapple 632
Orange 165
我想将两个系列合并为一个系列3
Company Product Price
ABC Apple 1234
Orange 123
BCD Apple 123
Orange 751
PCT Pineapple 1066
Orange 165
Beef 884
我尝试使用
series3 = pd.concat([series1,series2]).sum(level=1)
但是,它不能产生我想要的东西。预先谢谢你
答案 0 :(得分:0)
您可以尝试使用groupby
series3 = pd.concat([df,df1]).groupby(level=[0,1]).sum()
# Output:
Company Product Price
ABC Apple 1234
Orange 123
BCD Apple 123
Orange 751
PCT Beef 884
Orange 165
Pineapple 1066