1import pandas as pd
2
3USERS = pd.DataFrame({'email':['a@g.com','b@g.com','b@g.com','c@g.com','d@g.com']})
4print (USERS)
5 email
60 a@g.com
71 b@g.com
82 b@g.com
93 c@g.com
104 d@g.com
11
12EXCLUDE = pd.DataFrame({'email':['a@g.com','d@g.com']})
13print (EXCLUDE)
14 email
150 a@g.com
161 d@g.com
17
1df = pd.merge(df1, df2, how='left', indicator='Exist')
2df['Exist'] = np.where(df.Exist == 'both', True, False)
3df = df[df['Exist']==True].drop(['Exist','z'], axis=1)
4