Pandas使用pandas数据框索引来更新同一索引上的另一个数据框

时间:2019-09-18 12:54:24

标签: python pandas

我有2个熊猫数据框。我正在尝试根据匹配的索引用df中的值更新df2

df
    Url_Sub_Fld     ip
0   tel             na
1   li              na
2   192.22.25.26    192.22.25.26

df2
   Url_Sub_Fld
1  test_string

所需的输出:

df
    Url_Sub_Fld     ip
0   tel             na
1   test_string     na
2   192.22.25.26    192.22.25.26

1 个答案:

答案 0 :(得分:0)

已经22个小时了,没有答案,所以我将发布anky_91的评论,因为这是我用来解决问题的方式。

df.update(df2['Url_Sub_Fld'])
相关问题