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

Join 2 pandas dataframes by adding rows with the same index

I am struggling to join two dataframes by index (I’ve made column FileName an index for both tables) which look like this:

Table 1

FileName Transcriber Transcription
612_000002.wav 100% (80/80) Are we starting off?
612_000002.wav 100% (50/50) shall we starting on
612_000002.wav 100% (2/2) fast mode
612_000002.wav 100% (258/259) Go and start it up
612_000002.wav 100% (20/20) Are we starting off?
612_000003.wav 100% (258/259) here we go, hey well woah woah woah
612_000003.wav 100% (23/23) evening gulf air
612_000003.wav 100% (32/32) And as the 1st group reached the bottom of the…
612_000003.wav 100% (80/80) Happy to go off here, woah woah woah
612_000003.wav 100% (10/10) Go boom we’ll just

Table 2 is similar and looks like this:

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

FileName Transcriber Transcription
612_000002.wav Quartznet there was not inl
612_000002.wav Transducer_M don’t start again
612_000002.wav Transducer_L do we start again
612_000003.wav Transducer_L anything off yeah i’m willing we’ll just
612_000003.wav Transducer_S having gone here on will and wolf is

So I’ve looked into concat, merge, and join. But they don’t seem to yield the output I am looking for. What I would like to have is all values from both tables for filename1, all values for filename2 and etc. Basically, adding rows from table2 to table1. Is there any way around it?
Thank you <3

>Solution :

Use:

pd.concat([df1,df2]).drop_duplicates()
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