Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

dfA

     A
1    1
2    1
3    1
4    1

dfB

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

     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?

>Solution :

Try with update

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading