0

So I have this two DFs. This is DF1['nice_in_here']:

                         nice_in_here
0                                 NaN
1                            Krystyna
2                               Piotr  
3                            Domicela
4                                Jaro

This is DF2[['nice_in_there','current_club']]:

    nice_in_there               current_club
0   Krystyna                    Klub-Duzych-Pup
1   Elżbieta                    NaN
2   Domicela                    NaN
3   Piotr                       Klub-Duzych-Pup

So what i want is:

to check if DF2["nice_in_there"] is in DF1["nice_in_here"] and if so, I want to join corresponding DF2["current_club"] to DF1["nice-in_here"].

The result I want to have is (after typing DF1[['nice_in_here','current_club']]):

                         nice_in_here        current_club
0                                 NaN                 NaN
1                            Krystyna     Klub-Duzych-Pup
2                               Piotr     Klub-Duzych-Pup
3                            Domicela                 NaN
4                                Jaro                 NaN

Note that I don't want to drop NaN as missing value is important for me.

Please help, this is driving me mad!

cs95
  • 379,657
  • 97
  • 704
  • 746
MikolajM
  • 300
  • 1
  • 13

1 Answers1

0

This should work:

pd.merge(DF1, DF2, how="left", left_on="nice_in_here", right_on="nice_in_there") 
Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117