jack06215

[pandas] Remove exception data from another dataframe

Sep 26th, 2020 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. import pandas as pd
  2.  
  3.  
  4. EXCLUDE = pd.DataFrame({'email':['a@g.com','d@g.com']})
  5. USERS = pd.DataFrame({'email':['a@g.com','b@g.com','b@g.com','c@g.com','d@g.com']})
  6.  
  7. df_result = pd.merge(USERS, EXCLUDE, how='outer', indicator=True)
  8. df_result[df_result._merge == 'left_only'].drop(labels=['_merge'], axis=1)
  9.  
Add Comment
Please, Sign In to add comment