pandas dataframe filter multiple conditions same column 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: pandas two conditions filter
movies[(movies.duration >= 200) & (movies.genre == 'Drama')]