Here is how it looks:
group_by_genrebelow doing the following:
- Load the data in a
usecolsto get the table of genres and movies (
headerdid not work here).
- Split the genres, which are now separated by pipe (|) into separate rows. This is not trivial so we provided the
explodefunction mentioned in this article.
- Next filter out the 5 rows without a genre = (no genres listed). At this point your
DataFrameshould have a
shapeof (rows, columns):
- Lastly group the
DataFrameby genre, counting the number of movies for each. Sort the resulting
DataFrameon this count descending. This is how it should look: you should see Drama at the top and IMAX at the bottom.
Good luck, have fun and remember: keep calm and code in Python and
Note that our
pandasBites currently run on Python 3.6.