I've a sample dataframe df1
id user_id name email
1 1 John [email protected]
2 2 Alves [email protected]
3 3 Kristein [email protected]
4 4 James [email protected]
The second dataframe df2
id user user_email_1 user_email_2 status
1 Sanders [email protected] active
2 Alves [email protected] [email protected] active
3 Micheal [email protected] active
4 James [email protected] delete
How can I add the status data from df2
to df1
if
user_id
of df1
and id
of df2
name
of df1
and user
of df2
email
of df1
matches with user_email_1
or user_email_2
of df2
matches and drops the not matched records?
Desired Result df1
:
id user_id name email status
2 2 Alves [email protected] active
4 4 James [email protected] delete
For example:
As [email protected]
from df1
matches with user_email_2
, it appended the status data.