Skip to content

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

ColumnDescription
show_idThe ID of the show
typeType of show
titleTitle of the show
directorDirector of the show
castCast of the show
countryCountry of origin
date_addedDate added to Netflix
release_yearYear of Netflix release
durationDuration of the show in minutes
descriptionDescription of the show
genreShow genre
# Importing pandas and matplotlib
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Read in the Netflix CSV as a DataFrame
netflix_df = pd.read_csv("netflix_data.csv")
# Filter the dataFrame for movies released in the 1990s
movies_90s = netflix_df[(netflix_df['release_year'] >= 1990) & (netflix_df['release_year'] <= 1999)]
print(movies_90s)

# Find the most frequent movie duration
duration = movies_90s['duration'].mode().iloc[0] 
# The most frequent movie duration is found using the mode() function, which returns the most common value(s) in the duration column. We select the first mode using .iloc[0]
print(f"{duration} minutes")

# Visualise the data to view a distribution of movies duration
plt.figure(figsize=(10, 6))
sns.histplot(movies_90s['duration'], bins=30, kde=True)
# A histogram of movie durations is created using Seaborn's histplot function, with a kernel density estimate (KDE) overlay to better visualize the distribution
plt.title('Distribution of movies in the 1990s')
plt.xlabel('durarion (minute)')
plt.ylabel('frequency')
plt.axvline(duration, color='r', linestyle='--', label=f'mode: {duration} min')
plt.legend()
plt.show()

# Further subset the DataFrame to keep only action movies
action_movies_1990s = movies_90s[movies_90s['genre'].str.contains('Action', case=False, na=False)]
# The filtered DataFrame is further subsetted to include only action movies. The str.contains() method is used to check if the genre contains "Action", making the search case-insensitive and handling missing values (na=False).

# Count the number of short action movies (duration less than 90 minutes)
short_movie_count = sum(action_movie['duration'] < 90 for _, action_movie in action_movies_1990s.iterrows())
print(f"{short_movie_count}")
# The code iterates through the action_movies_1990s DataFrame, counting the number of movies with a duration less than 90 minutes.