0

I am looking to filter the Pandas Dataframe to select the data from two different types of attributes:

restaurants=df['restaurants'][df['restaurants']=='Español' or df['restaurants']=='Italiano']

But i can't use the option or for that could you give me an example of how to do it.

Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58
Ismael
  • 99
  • 1
  • 8

2 Answers2

1
restaurants=df[(df['restaurants']=='Español') | (df['restaurants']=='Italiano')] 
Suhas Mucherla
  • 1,383
  • 1
  • 5
  • 17
1
# method1
rest_list = ['Español', 'Italiano']
cond = df['restaurants'].isin(rest_list)
restaurants = df.loc[cond,'restaurants']

# method2
cond = False
cond |= df['restaurants']=='Español'
cond |= df['restaurants']=='Italiano'
restaurants = df.loc[cond,'restaurants']
Ferris
  • 5,325
  • 1
  • 14
  • 23