简体   繁体   中英

Pandas Using index of pandas dataframe to update another dataframe on same index

I have 2 pandas dataframes. I am trying to update df with values from df2 based on matching index's.

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

Desired output:

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

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

df.update(df2['Url_Sub_Fld'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM