-1

As someone who is super new in merge/append on Python, I am trying to merge two different DF together.

  • DF1 has 2 columns with Text and ID columns and 100 rows
  • DF2 has 3 columns with Text, ID, and Match columns and has 20 rows

My goal is to combine the two DFs together so the "Match" column from DF2 can be merged into DF1. The Match column is all "True" value, so when it gets merged over the other 80 rows on DF1 can be NaN and I can fix it later.

Thank you to everyone for the help and support!

hank_lang
  • 13
  • 1
  • Please provide your data. Vague explanation of the field might be unclear to many. – Mr. Hobo May 31 '21 at 18:40
  • Thank you so much for your comment! I am super new to Stack overflow so I don't really know what I am doing.... thank you for your patience. – hank_lang May 31 '21 at 18:42
  • To improve future questions, please include a small subset of your data as a copyable piece of code that can be used for testing as well as your expected output. For more information, see [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391). – AlexK May 31 '21 at 21:05

1 Answers1

1

Try a left merge using .merge(), like this:

DF_out = DF1.merge(DF2, on=['Text', 'ID'], how='left')
SeaBean
  • 22,547
  • 3
  • 13
  • 25
  • @hank_lang Welcome. Please [accept the answer](https://stackoverflow.com/help/someone-answers). – SeaBean May 31 '21 at 18:45