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")
netflix_df# Task 1: What was the most frequent movie duration in the 1990s? Save an approximate answer as an integer called duration (use 1990 as the decade's start year).
# Filter netflix dataframe for movies release in the 1990s (1990-1999)
set1 = netflix_df[ (netflix_df["release_year"] >= 1990) & (netflix_df["release_year"] < 2000) & (netflix_df["type"] == "Movie")]
# Show histogram for visual representation
plt.hist(set1[:]["duration"],bins = 50, range = (90, 100))
plt.show()
# plt.clt()
# Get the most frequent duration by using .mode() aggregate function, this matches what is shown in the histogram which is 94 minutes.
duration = set1["duration"].mode()[0]# Task 2: Count the number of short action movies (duration of less than 90 minutes) in the 1990s, save as short_movie_count (int)
# Re-use set1 subset since it is a set of movies from 1990s
# Subset/filter for less than 90 minutes duration and action genre
set2 = set1[np.logical_and(set1["genre"] == "Action", set1["duration"] < 90)]
# Calculate for the number of short action 1990s movies using len which is 7.
short_movie_count = len(set2)
# For visual representation of how many short action 1990s there are
plt.bar(set2["duration"].value_counts().index, set2["duration"].value_counts().values)
plt.xlabel("Duration")
plt.ylabel("Frequency")
plt.show()# to verify set0 subset
set1set2