Skip to content

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 pandas and matplotlib
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")

year_nf = netflix_df['date_added'].str.split(',', n=1, expand=True)

netflix_df['date_added_nf'] = year_nf[0]
netflix_df['year_added'] = year_nf[1].astype('int')
display(netflix_df)
# Start coding here! Use as many cells as you like
duration = netflix_df.duration.mean().round().astype('int')
duration
action = netflix_df[netflix_df['genre'] == 'Action']
nineties_action = action[(action['release_year'] > 1989) & (action['release_year'] < 2000)].reset_index()
short_movie_count = nineties_action[nineties_action['duration'] < 90].show_id.count()
short_movie_count

Exploration

Movies vs. TV Shows

# Years
s_2016 = netflix_df[netflix_df['year_added'] == 2016]
s_2017 = netflix_df[netflix_df['year_added'] == 2017]
s_2018 = netflix_df[netflix_df['year_added'] == 2018]
s_2019 = netflix_df[netflix_df['year_added'] == 2019]
s_2020 = netflix_df[netflix_df['year_added'] == 2020]
s_2021 = netflix_df[netflix_df['year_added'] == 2021]

# Type by Year
type_2016 = s_2016.groupby('type')['show_id'].count()
type_2017 = s_2017.groupby('type')['show_id'].count()
type_2018 = s_2018.groupby('type')['show_id'].count()
type_2019 = s_2019.groupby('type')['show_id'].count()
type_2020 = s_2020.groupby('type')['show_id'].count()

type_df = pd.DataFrame(type_2016)
type_df.rename(columns={'show_id':'type_2016'}, inplace=True)

type_df['type_2017'] = type_2017
type_df['type_2018'] = type_2018
type_df['type_2019'] = type_2019
type_df['type_2020'] = type_2020

display(type_df)

Movies Breakdown

# Movies
mov_2016 = s_2016[s_2016['type'] == 'Movie']
mov_2017 = s_2017[s_2017['type'] == 'Movie']
mov_2018 = s_2018[s_2018['type'] == 'Movie']
mov_2019 = s_2019[s_2019['type'] == 'Movie']
mov_2020 = s_2020[s_2020['type'] == 'Movie']

# No. of Movies by Year
sum_2016 = mov_2016.shape[0]
sum_2017 = mov_2017.shape[0]
sum_2018 = mov_2018.shape[0]
sum_2019 = mov_2019.shape[0]
sum_2020 = mov_2020.shape[0]

# Percent Increases
inc_16_17 = round(((sum_2017 - sum_2016)/sum_2016) * 100)
inc_17_18 = round(((sum_2018 - sum_2017)/sum_2017) * 100)
inc_18_19 = round(((sum_2019 - sum_2018)/sum_2018) * 100)
inc_19_20 = round(((sum_2020 - sum_2019)/sum_2019) * 100)


print('2016 to 2017 Movie Increase:', inc_16_17, '%')
print('2017 to 2018 Movie Increase:', inc_17_18, '%')
print('2018 to 2019 Movie Increase:', inc_18_19, '%')
print('2019 to 2020 Movie Increase:', inc_19_20, '%')

TV Shows Breakdown

# TV Shows
tv_2016 = s_2016[s_2016['type'] == 'TV Show']
tv_2017 = s_2017[s_2017['type'] == 'TV Show']
tv_2018 = s_2018[s_2018['type'] == 'TV Show']
tv_2019 = s_2019[s_2019['type'] == 'TV Show']
tv_2020 = s_2020[s_2020['type'] == 'TV Show']
tv_2021 = s_2021[s_2021['type'] == 'TV Show']

# No. of TV Shows by Year
tot_2016 = tv_2016.shape[0]
tot_2017 = tv_2017.shape[0]
tot_2018 = tv_2018.shape[0]
tot_2019 = tv_2019.shape[0]
tot_2020 = tv_2020.shape[0]

# Percent Increases
in_16_17 = round(((tot_2017 - tot_2016)/tot_2016) * 100)
in_17_18 = round(((tot_2018 - tot_2017)/tot_2017) * 100)
in_18_19 = round(((tot_2019 - tot_2018)/tot_2018) * 100)
in_19_20 = round(((tot_2020 - tot_2019)/tot_2019) * 100)


print('2016 to 2017 TV Show Increase:', in_16_17, '%')
print('2017 to 2018 TV Show Increase:', in_17_18, '%')
print('2018 to 2019 TV Show Increase:', in_18_19, '%')
print('2019 to 2020 TV Show Increase:', in_19_20, '%')

Visualization of Movies by Year

import matplotlib.pyplot as plt
import seaborn as sns

x = ['2016', '2017', '2018', '2019', '2020']
y = [sum_2016, sum_2017, sum_2018, sum_2019, sum_2020]

sns.barplot(x=x, y=y, hue=y, palette='Set2', legend=False)

plt.plot(x, y, color='black', linestyle='--')
plt.scatter(x, y, color='red')

plt.title('Movies by Year', weight='bold', fontsize=16)
plt.xlabel('Years', style='italic', weight='bold')
plt.ylabel('No. of Movies', style='italic', weight='bold')

plt.show()

Visualization of TV Shows by Year