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
Column | Description |
---|---|
show_id | The ID of the show |
type | Type of show |
title | Title of the show |
director | Director of the show |
cast | Cast of the show |
country | Country of origin |
date_added | Date added to Netflix |
release_year | Year of Netflix release |
duration | Duration of the show in minutes |
description | Description of the show |
genre | Show genre |
# Importing pandas and matplotlib
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# Read in the Netflix CSV as a DataFrame
netflix_df = pd.read_csv("netflix_data.csv")
# Start coding here! Use as many cells as you like
display(netflix_df)
EDA
# Explore the dataset
netflix_df.describe()
# Plot the distribution of the numerical variables
# 1. release_year
plt.hist(netflix_df['release_year'])
plt.yticks(range(0,4000,500))
plt.title("Distribution of the Movies over the years")
plt.show()
plt.clf()
# Comments: Most of the movies released post the 1990's with the number of releases increasing 3 times post 2010
# 2. duration
plt.hist(netflix_df['duration'],bins = 20)
#plt.yticks(range(200,2000,250))
plt.xticks(range(0,250,25))
plt.title("Duration of the Movies over the years")
plt.show()
plt.clf()
# Comments: Most of the movies are between 75 to 125 minutes , with the maximum being 100 minutes.
Findings
- Most of the movies released post the 1990's with the number of releases increasing 3 times post 2010.
- Most of the movies are between 75 to 125 minutes , with the maximum being 100 minutes.
# What was the most frequent movie duration in the 1990s? Save an approximate answer as an integer called duration.
# 1. Filter only the Movies
movies = netflix_df[netflix_df['type'] == 'Movie']
display(movies)
# 2. Filter the years between 1990 - 1999
movies_1990 = movies[np.logical_and(movies['release_year'] >= 1990, movies['release_year'] <= 1999 )]
display(movies_1990)
# View the distribution of the filtered data frame to confirm that the filters were correct
movies_1990.describe()
# View the most frequent movie duration in 1990's
duration = int(np.median(movies_1990['duration']))
print("The most frequent movie duration is: " + str(duration))
# Find the movies with the most frequent movie duration
max_movie_duration = np.median(movies_1990['duration'])
# Find the rows with the most frequent movie duration
max_movie_duration = movies_1990[movies_1990['duration'] == max_movie_duration]
display(max_movie_duration)
# A movie is considered short if it is less than 90 minutes. Count the number of short action movies released in the 1990s and save this integer as short_movie_count.
# Step 1: Filter the movies by 'genre'.
# a. Long method
#action_movies = movies_1990['genre'] == 'Action'
#short_action_movies = movies_1990[action_movies]
# b. Short method
action_movies = movies_1990[movies_1990['genre'] == 'Action']
display(action_movies)
# Step 2. Filter the action movies which has a duration < 90 minutes
short_action_movies = action_movies[action_movies['duration'] < 90]
short_movie_count = len(short_action_movies)
print("The number of short action movies is: " + str(short_movie_count))