Here is what my two dataframes look like:
DF1
NAME EMAIL ID
Mark [email protected] 8974
Sam [email protected] 9823
June [email protected] 0972
David [email protected] 2143
DF2
ID ROLE-ID
2143 22
0972 34
8974 98
9823 54
What I need to help doing:
I need to COMPARE the ID column for both dataframes and if the ID from DF1 MATCHES with the ID of DF2, I need to replace the ID column in DF1 with the respective ROLE-ID from DF2.
The output would look like this:
Updated DF1
NAME EMAIL ROLE-ID
Mark [email protected] 98
Sam [email protected] 54
June [email protected] 34
David [email protected] 22
I am using the Pandas library and tried the merge function with conditions but it didnt work
print(pd.merge(df1, df2, on=(df1['Id'] == df2[])))