filter dataframe with 2 conditions with or code example
Example 1: how to filter pandas dataframe column with multiple values
movies[movies.duration >= 200]
movies[(movies.duration >= 200) & (movies.genre == 'Drama')]
movies[(movies.duration >= 200) | (movies.genre == 'Drama')]
(movies.duration >= 200) | (movies.genre == 'Drama')
(movies.duration >= 200) & (movies.genre == 'Drama')
movies[(movies.genre == 'Crime') | (movies.genre == 'Drama') | (movies.genre == 'Action')]
filter_list = ['Crime', 'Drama', 'Action']
movies[movies.genre.isin(filter_list)]
Example 2: filter dataframe multiple conditions
movies[(movies.duration >= 200) & (movies.genre == 'Drama')]