简体   繁体   English

在索引重叠上用另一个 dataframe 中的另一个列更新 pandas dataframe 列

[英]Update pandas dataframe column with another column in another dataframe on index overlap

I wish to update column A in dfA with column B in dfB on index overlap我希望在索引重叠时用 dfB 中的 B 列更新 dfA 中的 A 列

dfA自由度

     A
1    1
2    1
3    1
4    1

dfB东风

     B
3    2
4    2
5    2
6    2

Desired result:期望的结果:

     A
1    1
2    1
3    2
4    2

What is the simplest way to do this?最简单的方法是什么?

Try with update尝试update

dfA.update(dfB.rename(columns = {'B':'A'}))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 熊猫:根据另一个数据框中的索引更新列 - Pandas: update a column based on index in another dataframe 如何根据另一个 DataFrame 中的列更新 Pandas DataFrame 中的列 - How to update a column in pandas DataFrame based on column from another DataFrame 基于同一 dataframe 的另一列更新 pandas dataframe 中的列 - Update column in pandas dataframe based on another column of the same dataframe 用另一个 DataFrame 替换 pandas 多索引 DataFrame 的列 - Replace column of pandas multi-index DataFrame with another DataFrame 根据索引使Pandas Dataframe列等于另一个Dataframe中的值 - Make Pandas Dataframe column equal to value in another Dataframe based on index 如果pandas数据框列中的值存在于另一个数据框中,则更新它们 - Update values in pandas dataframe column if they exist in another dataframe Pandas 更新并添加第一行 dataframe 和另一个 dataframe 中的键列 - Pandas update and add rows one dataframe with key column in another dataframe 当来自熊猫中另一个数据框的键匹配时更新数据框的列 - Update column of a dataframe when key matches from another dataframe in pandas 使用来自另一个具有条件的数据帧的值更新熊猫数据帧列 - update pandas dataframe column with value from another dataframe with condition pandas 在列值匹配时使用来自另一个数据帧的值更新数据帧 - pandas update a dataframe with values from another dataframe on the match of column values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM