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. Our friend has also been brushing up on their Python skills and has taken a first crack at a CSV file containing Netflix data. They believe that the average duration of movies has been declining. Using your friends initial research, you'll delve into the Netflix data to see if you can determine whether movie lengths are actually getting shorter and explain some of the contributing factors, if any.

You have been supplied with the dataset netflix_data.csv , along with the following table detailing the column names and descriptions:

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 , numpy and matplotlib
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

Load the CSV file and store as netflix_df.

# loading dataset and saving into pandas dataframe
netflix_df = pd.read_csv('netflix_data.csv')

# printing first five rows of original netflix_df dataset
netflix_df.head() 
# generating information about netflix_df dataset
netflix_df.info()
  • we see that there are total 11 data columns
  • Index range of entries starting (0-7786)
  • 9 object data type categorical columns and 2 int numerical data type columns for staistical description.
# checking for shape of dataset (rows and columns)
print(f' There are {netflix_df.shape[0]} rows and {netflix_df.shape[1]} columns in the dataset' )
# checking for null values
netflix_df.isna().sum()

we see that netflix dataset contains null values in following columns

  • director 2389
  • cast 718
  • country 507
  • date_added 10
#  Plot null values
netflix_df.isna().sum().plot(kind="bar")
plt.title('Null Values')
plt.show()
# checking value count of each element of type column before filtering
netflix_df['type'].value_counts()

Filtering data and creating netflix subset

# Filter the data to remove TV shows and store as netflix_subset.

netflix_subset = netflix_df[netflix_df['type']!='TV Show']

netflix_subset.head()
# checking & veryfying count of type element after filtering 
print(f'Total count of netflix_df was', (len(netflix_df)),"\n",
      'Total count of netflix_subset after filtering data is',(len(netflix_subset)))