python - Pandas 使用 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
解决方案
已经 22 小时没有答案,所以我将发布 anky_91 的评论,因为这是我用来解决问题的方法。
df.update(df2['Url_Sub_Fld'])
推荐阅读
- python - 如何显示所有标签内容?
- c# - 无法在预制件内实例化预制件
- mysql - 将字符从数据库提取到另一个包含所有项目的数据库
- google-sheets - 在 Google Sheet 图表中可视化每月的输入和输出(流量)率
- django - 带有 ManyToManyField 的 Django Rest Framework 自定义权限类
- c# - 我应该将 RabbitMQ 消费者与其余代码分开吗?
- visual-studio-2012 - Visual Studio SR 报告加入来自多个数据集的数据?
- jquery - 使用 jQuery,我如何从几个中找出特定的类
- javascript - 如何将隐藏搜索功能添加到我的离线收藏网站
- python - 如何在 Quantlib python 中注销可观察对象?