df 1:
Condition Currency Total Hours
0 Used USD 100
1 Used USD 75
2 Used USD 13
3 Used USD NaN
df 2:
Condition Currency Total Hours
1 Used USD 99
3 New USD 1000
Desired Result:
Condition Currency Total Hours
0 Used USD 100
1 Used USD 99
2 Used USD 13
3 New USD 1000
我如何使用第一列作为索引(索引)合并两个数据帧,并用df2的值覆盖df1的值?
我尝试了各种变体,但似乎没有任何效果。我试过的几个例子:
pd.merge(df, df1) = result is an empty dataframe
df.combine_first(df1) = the result is a dataframe but with the same values as df1
答案 0 :(得分:1)
尝试a[5]
:
update
输出:
df.update(df2)
print(df)