Skip to Content
Numerical Computing with Python
book

Numerical Computing with Python

by Pratap Dangeti, Allen Yu, Claire Chung, Aldrin Yim
December 2018
Beginner to intermediate
682 pages
18h 1m
English
Packt Publishing
Content preview from Numerical Computing with Python

How to do it...

  1. Read in the movie dataset, set the index as the title, and then create a boolean Series matching all movies with a content rating of G and an IMDB score less than 4:
>>> movie = pd.read_csv('data/movie.csv', index_col='movie_title')>>> c1 = movie['content_rating'] == 'G'>>> c2 = movie['imdb_score'] < 4>>> criteria = c1 & c2
  1. Let's first pass these criteria to the .loc indexer to filter the rows:
>>> movie_loc = movie.loc[criteria]>>> movie_loc.head()
  1. Let's check whether this DataFrame is exactly equal to the one generated directly from the indexing operator:
>>> movie_loc.equals(movie[criteria])True
  1. Now let's attempt ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Numerical Computing with NumPy

Mastering Numerical Computing with NumPy

Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu

Publisher Resources

ISBN: 9781789953633OtherOtherErrata Page