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
# Read in the Netflix CSV as a DataFrame
netflix_df = pd.read_csv("netflix_data.csv")Guided question: What was the most frequent movie duration in the 1990s? Save an as an integer called most_frequent.
SELECT duration, COUNT(duration) AS most_frequent
FROM netflix_df
WHERE release_year BETWEEN 1990 AND 1999
AND type = 'Movie'
GROUP BY duration
ORDER BY COUNT(duration) DESCMovie Duration (in minutes) in 1990s
The most frequent duration for movies in the 1990's was 94 minutes.
Guided question: 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.
SELECT title, type, genre, duration
FROM netflix_df
WHERE release_year BETWEEN 1990 AND 1999
First, I preview the data in the columns of title, type, duration and genre so I make sure that I am filtering for just the movies.
Then, I refine the code to select movies that are only Action and less than 90 minutes and add a count feature to get the total number of movies that are less than 90 minutes saved as an integer short_movie_count.
SELECT COUNT(*) AS short_movie_count
FROM netflix_df
WHERE release_year BETWEEN 1990 AND 1999
AND type = 'Movie'
AND genre = 'Action'
AND duration < 90I end up with a total of 7 Action movies that are less than 90 minutes.
Which movies are these? We can replace count with title in the code to see the titles of these movies.
SELECT title
FROM netflix_df
WHERE release_year BETWEEN 1990 AND 1999
AND type = 'Movie'
AND genre = 'Action'
AND duration < 90What if I want to see the number of movies in each genre in the database?
I would use a similar code as above but change the COUNT from counting duration to counting genres and group by genre.
SELECT genre, COUNT(genre) AS number_per_genre
FROM netflix_df
WHERE release_year BETWEEN 1990 AND 1999
AND type = 'Movie'
GROUP BY genre
ORDER BY COUNT(genre) DESCNumber of Movies in Database per Genre