I have two dataframes one has the ID and Name and one just has the Name. I want to match the name to the ID and for those without a ID leave as null.
DF1:
ID Name
1 John Doe
2 Mary Sue
3 Josh Smith
4 Sarah Moore
DF2:
Name
Sarah Moore
John Doe
Josh Smith
Mary Sue
Josh Gordon
Desired output:
ID Name
4 Sarah Moore
1 John Doe
3 Josh Smith
2 Mary Sue
NA Josh Gordon
I've tried merging but have not gotten the results I needed
df2 = df2.merge(df2,df1['ID'], on = 'Name', how = 'left')
Any suggestions?