Reputation: 1946
Thanks for taking the time to read my question.
I have two dataframes:
df_1
Contains: Ticket_ID and Email_Address
df_2
Contains: Email_Address and MachineID
I need to search df_2 using the email addresses in df_1 and if there is a match, write the MachineID to a new column in df_1.
I can do one off queries using DataFrame.query but I'm not sure how to pass the list of email addresses from df_1.
Thanks!
Upvotes: 0
Views: 507
Reputation: 862511
I think you can use merge
:
print df_1
Ticket_ID Email_Address
0 100 [email protected]
1 200 [email protected]
print df_2
Email_Address MachineID
0 [email protected] 9
1 [email protected] 2
2 [email protected] 3
print pd.merge(df_1, df_2, on=['Email_Address'], how='left')
Ticket_ID Email_Address MachineID
0 100 [email protected] 9
1 200 [email protected] NaN
Upvotes: 2