How to do it...

  1. Load in the movie dataset and set the index as the title:
>>> movie = pd.read_csv('data/movie.csv', index_col='movie_title')
  1. Create a variable to hold each set of criteria independently as a boolean Series:
>>> criteria1 = movie.imdb_score > 8
>>> criteria2 = movie.content_rating == 'PG-13'
>>> criteria3 = ((movie.title_year < 2000) |
(movie.title_year > 2009))

>>> criteria2.head() # all criteria Series look similar
movie_title Avatar True Pirates of the Caribbean: At World's End True Spectre True The Dark Knight Rises True Star Wars: Episode VII - The Force Awakens False Name: content_rating, dtype: bool
  1. Combine all the criteria together into a single boolean Series:
>>> criteria_final = criteria1 & criteria2 & criteria3
>>> criteria_final.head()
movie_title Avatar False Pirates of the Caribbean: At World's End False Spectre False The Dark Knight Rises True Star Wars: Episode VII - The Force Awakens False dtype: bool
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.172.130