Home > OS >  Update pandas dataframe column with another column in another dataframe on index overlap
Update pandas dataframe column with another column in another dataframe on index overlap

Time:09-21

I wish to update column A in dfA with column B in dfB on index overlap

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?

CodePudding user response:

Try with update

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