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.

1
  • 2
    Use: df[df['restaurants']=='Español' | df['restaurants']=='Italiano'] Commented Dec 29, 2020 at 10:02

2 Answers 2

1
restaurants=df[(df['restaurants']=='Español') | (df['restaurants']=='Italiano')] 
Sign up to request clarification or add additional context in comments.

Comments

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']

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.