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
df = pd.read_csv('netflix_data.csv')# Get data info
df.info()#filter to the 1990s
nineties_df = df[(df['release_year'] >= 1990) & (df['release_year']<=1999)] # don't forget to use parentheses when using multiple conditions
nineties_df.info()"""What was the most frequent movie duration in the 1990s?"""
duration_counts = nineties_df[['duration']].value_counts(ascending=False)
print(duration_counts)
plt.hist(nineties_df[['duration']], bins=10)
plt.show()# ANS
"""What was the most frequent movie duration in the 1990s?"""
#get the value with the highest frequency count in the duration column
duration = nineties_df['duration'].value_counts().idxmax()
print(duration)
#idxmax returns the label, not the frequency count
nineties_df.genre.value_counts#ANS
"""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."""
#filter to action movies
nineties_action = nineties_df[nineties_df['genre'] =='Action']
#get the 90 minutes or less count
short_movies = nineties_action[nineties_action['duration'] <= 90]
#print(short_movies)
#get the count
short_movie_count = short_movies.shape[0]
print(short_movie_count)#check the long movies
long_movies = nineties_action[nineties_action['duration'] > 90]
#get the count
long_movie_count = long_movies.shape[0]
print(long_movie_count)
#plotting
categories = ['Short movies', 'Long movies']
counts = [short_movie_count, long_movie_count]
plt.bar(categories, counts)
#adding labels to the bars
for i, count in enumerate(counts):
plt.text(i, count + 0.5, str(count), ha='center', va='bottom')
plt.title('Number of Short vs Long Action Movies')
plt.show()