Guest User

Untitled

a guest
Jul 11th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. df = pd.DataFrame({'email': ['foo@bar.com', 'bar@bar.com', 'bar@foo.com']})
  2.  
  3. email
  4. 0 foo@bar.com
  5. 1 bar@bar.com
  6. 2 bar@foo.com
  7.  
  8. df['before'] = df.email.str.split('@').str.get(0).str.contains('foo')
  9. df['after'] = df.email.str.split('@').str.get(1).str.contains('foo')
  10.  
  11.  
  12.  
  13. email before after
  14. 0 foo@bar.com True False
  15. 1 bar@bar.com False False
  16. 2 bar@foo.com False True
Add Comment
Please, Sign In to add comment