I've a sample dataframe df1
id user_id name email
1 1 John John@example.com
2 2 Alves alves@example.com
3 3 Kristein kristein@example.com
4 4 James james@example.com
The second dataframe df2
id user user_email_1 user_email_2 status
1 Sanders sanders@example.com active
2 Alves alves111@example.com alves@example.com active
3 Micheal micheal@example.com active
4 James james@example.com 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 alves@example.com active
4 4 James james@example.com delete
For example:
As alves@example.com
from df1
matches with user_email_2
, it appended the status data.