0

I have a dataframe with columns "sender","recipient","subject", "body". I need to filter the data with an emailid which is in sender or recipient column

df_new=df.loc[(df['sender'] == searchEmail) | (df['recipient'] == searchEmail)]

Filtering is working perfectly, but after filtering print(df_new) shows "subject" and "body" columns are filled with some other data. What is the issue here?

Ajoe
  • 1,397
  • 4
  • 19
  • 48
  • See [How to make good reproducible pandas examples](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) and make changes to your Q. – Zero Jul 18 '17 at 12:07
  • @DeepSpace .loc is not making any difference to my issue :( – Ajoe Jul 18 '17 at 12:20

1 Answers1

0

You can use

df[df['subject'].str.contains("hello")]


df[df['body'].str.contains("hello")]
Beyhan Gul
  • 1,191
  • 1
  • 15
  • 25