Skip to content

1 hidden cell

Netflix! What started in 1997 as a DVD rental service has since exploded into one of the largest entertainment and media companies.

Given the large number of movies and series available on the platform, it is a perfect opportunity to flex your exploratory data analysis skills and dive into the entertainment industry.

You work for a production company that specializes in nostalgic styles. You want to do some research on movies released in the 1990's. You'll delve into Netflix data and perform exploratory data analysis to better understand this awesome movie decade!

You have been supplied with the dataset netflix_data.csv, along with the following table detailing the column names and descriptions. Feel free to experiment further after submitting!

The data

netflix_data.csv

ColumnDescription
show_idThe ID of the show
typeType of show
titleTitle of the show
directorDirector of the show
castCast of the show
countryCountry of origin
date_addedDate added to Netflix
release_yearYear of Netflix release
durationDuration of the show in minutes
descriptionDescription of the show
genreShow genre
# Importing numpy, pandas and matplotlib
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Read in the Netflix CSV as a DataFrame
netflix_df = pd.read_csv("netflix_data.csv")
# Step 1 : Filtering movies from the 1990s
movies_90s = netflix_df[
    (netflix_df["release_year"] >= 1990) &
    (netflix_df["release_year"] <= 1999) &
    (netflix_df["type"] == "Movie")
]
# Step 2 : Visualizing most frequent duration with matplotlib

# Experimenting with bins size
bins = np.arange(
    round(min(movies_90s["duration"])-10,-1),
    round(max(movies_90s["duration"])+10,-1)+5,
    10
)
print(min(movies_90s["duration"]))
print(round(min(movies_90s["duration"])-10,-1))
print(max(movies_90s["duration"]))
print(round(max(movies_90s["duration"])+10,-1)+5)
print(bins)

plt.hist(
    movies_90s["duration"],
    bins
)
plt.title("90s movies duration")
plt.xlabel("Minutes")
plt.xticks(np.arange(0,max(movies_90s["duration"])+10,5),minor=True)
plt.ylabel("Nb of movies")
plt.yticks(np.arange(0,19,1),minor=True)
plt.grid()

# From histogram we see that the most frequent duration is between 100 and 105
duration = 100
# Step 3 : Counting short movies

# 3.1 : Filtering on action movies
short_action_movies = movies_90s[movies_90s["genre"] == "Action"]
# 3.2 Counting the nb of row 
short_movie_count = (short_action_movies["duration"]<90).sum()
# This works because (short_action_movies["duration"] < 90) returns a Serie of type bool (True = 1 and False = 0) :
# Check result : print(short_action_movies["duration"]<90)

# Alternative solution : filter directly on duration then count nb of row
alt_short_action_movies = movies_90s[(movies_90s["genre"] == "Action") & (movies_90s["duration"] < 90)]
alt_short_movie_count = alt_short_action_movies["duration"].count()

# (Printing differents values to see if count makes sense)
print("Nb of short action movies : "+str(short_movie_count))
print("Alt nb of short action movies : "+str(alt_short_movie_count))
print("Nb of 90s movies : "+str(movies_90s["show_id"].count()))
print("Total nb of Netflix contents : "+str(netflix_df["show_id"].count()))