考虑两个数据帧: df 1:
ID value1 value2 result
1 50 -50 1111
2 20 -20 2222
3 -75.50 25 3333
df 2:
ID value3 value4 result
101 20 -20
201 -75.50 25
756 50 -50
如何使用Python将结果与正确的列匹配?
答案是:
ID value3 value4 result
101 20 -20 2222
201 -75.50 25 3333
756 50 -50 1111
答案 0 :(得分:0)
了解合并 https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html
pd.merge( df1, df2,
left_on = ["value1","value2"],
right_on = ["value3","value4"] )