我有一个如下所示的数据框:
Plant Date Item unitsSold
1 10-oct A 15
1 11-Oct A 20
1 12-Oct A 10
2 10-Oct B 19
2 11-Oct A 20
2 12-Oct C 10
另一个数据集如下所示:
Plant Date Item unit Price
1 10-Oct A,B 10 ---That means both A and B have same unit price
1 11-Oct A 14
1 12-Oct A,B,C 10 ----That means both A, B and C have same price
2 10-oct A,B,C 15
2 11-Oct A 10
3 12-Oct A,C 20
现在我希望我的输出看起来像这样:
Plant Date Item unit Price A.UnitsSold B.Unitssold C.unitssold
1 10-Oct A,B 10 15 0 0 --Since only a was sold on 10-oct
1 11-Oct A 14 20 0 0
1 12-Oct A,B,C 10 10 0 0
2 10-oct A,B,C 15 0 19 0
2 11-Oct A 10 20 0 0
3 12-Oct A,C 20 0 0 10
谁能告诉我如何获取已售单位的列。注意-可以有任意数量的样式
最佳答案
与列合并
df_new =pd.concat([df1, df2], axis=1)
关于python - 以列格式将一个表的输出合并到另一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58968320/