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
# Ensuring all comlumns show with .head()
pd.set_option("display.max_columns", None)
# Reading in the file
netflix_df = pd.read_csv("netflix_data.csv")
# Restricting to only movies that were made in the 1990s
netflix_df = netflix_df[(netflix_df["type"] == "Movie") & (netflix_df["release_year"].between(1990,1999))]
# Ensuring this worked:
# Type
print("Type: \n", str(netflix_df['type'].value_counts()))
#Release year
print("Release year range \n:", str(movies90s['release_year'].min()), " to ", str(movies90s['release_year'].max()))
# Note. 183 movies between 1990 and 1999
# Dropping variables not needed for analysis
netflix_df = netflix_df.drop(columns=['type', 'title', 'director', 'cast', 'country', 'date_added', 'release_year', 'description'])# Initial Datachecks
# Looking at the data
print(netflix_df.head())
# Checking variable datatypes
print("Datatypes \n", str(netflix_df.dtypes))
#Note. 'type' and 'genre' needed to be recoded as categorical
# Checking for missing data
print("N of missing data per variable\n", str(netflix_df.isna().sum()))# Data cleaning
# Setting the show id as the index
netflix_df = netflix_df.set_index('show_id')
# Changing 'genre' to a 'categorical variables'
netflix_df['genre'] = netflix_df['genre'].astype('category')
# Re-checking the new datatypes
print("Datatypes \n", str(netflix_df.dtypes))# Data Exploration
# Genre
print("Genre \n", str(netflix_df['genre'].value_counts()))
# N=48 for action movies
# Duration
print("Duration \n", str(netflix_df['duration'].describe()))
# Range is 28 to 195 minutes.
# Median: 108 minutes (IQR: 94, 136)# Solving the exercises
# Find the most frequent movie duration and save as an integer named 'duration'
duration = int(netflix_df["duration"].mode())
print("The most frequent movie duration in the 1990s is:\n" + str(duration))
# Finding the number of short (< 90 min) action movies and save as an integer named 'short_movie_count'
short_movie_count = int(len(netflix_df[(netflix_df["genre"] == "Action") & (netflix_df["duration"] < 90)]))
print("The number of short action 1990s movies is:\n" + str(short_movie_count))