I would like to Merge and match using Pandas
Data
df1
ID name stat
aa678 TRUE 112
aa678 FALSE 111
bb131 TRUE 122
df2
ID2 Box
aa678 santa fe
cc121 delux
Desired
ID name stat Box
aa678 TRUE 112 santa fe
aa678 FALSE 111 santa fe
bb131 TRUE 122
Doing
df1.join(df2.set_index('ID'), on = 'ID2')
However, this is not giving the desired result and not showing the values that do not have matches.
Any suggestion is appreciated.
>Solution :
Use merge which does the same thing but offers more flexibility:
df1.merge(df2, left_on="ID", right_on="ID2", how="left")