Skip to content
Investigating Netflix Movies and Guest Stars in The Office
  • AI Chat
  • Code
  • Report
  • 1. Welcome!

    Markdown.

    The Office! What started as a British mockumentary series about office culture in 2001 has since spawned ten other variants across the world, including an Israeli version (2010-13), a Hindi version (2019-), and even a French Canadian variant (2006-2007). Of all these iterations (including the original), the American series has been the longest-running, spanning 201 episodes over nine seasons.

    In this notebook, we will take a look at a dataset of The Office episodes, and try to understand how the popularity and quality of the series varied over time. To do so, we will use the following dataset: datasets/office_episodes.csv, which was downloaded from Kaggle here.

    This dataset contains information on a variety of characteristics of each episode. In detail, these are:

    datasets/office_episodes.csv
    • episode_number: Canonical episode number.
    • season: Season in which the episode appeared.
    • episode_title: Title of the episode.
    • description: Description of the episode.
    • ratings: Average IMDB rating.
    • votes: Number of votes.
    • viewership_mil: Number of US viewers in millions.
    • duration: Duration in number of minutes.
    • release_date: Airdate.
    • guest_stars: Guest stars in the episode (if any).
    • director: Director of the episode.
    • writers: Writers of the episode.
    • has_guests: True/False column for whether the episode contained guest stars.
    • scaled_ratings: The ratings scaled from 0 (worst-reviewed) to 1 (best-reviewed).
    # 1
    
    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    
    office_episodes = pd.read_csv('datasets/office_episodes.csv')
    
    colours = []
             
    for index, column in office_episodes.iterrows():
        if column['scaled_ratings'] < 0.25:
            colours.append('Red')
        elif (column['scaled_ratings'] >= 0.25) and (column['scaled_ratings'] < 0.50):
             colours.append('orange')
        elif (column['scaled_ratings'] >= 0.50) and (column['scaled_ratings'] < 0.75):
             colours.append('lightgreen')
        else:
             colours.append('darkgreen')
    
    marker_size = []
    
    for index, column in office_episodes.iterrows():
        if column['has_guests'] == True:
            marker_size.append(250)
        else:
            marker_size.append(25)
            
    office_episodes['marker_size'] = marker_size
    office_episodes['colour'] = colours
    print(office_episodes.info())
    
    ep_no_guests = office_episodes[office_episodes['has_guests'] == False]
    ep_has_guests = office_episodes[office_episodes['has_guests'] == True]
    
    plt.rcParams['figure.figsize'] = [11, 7]
    fig = plt.figure()
    
    plt.scatter(x = ep_no_guests['episode_number'],
                y = ep_no_guests['viewership_mil'], 
                c = ep_no_guests['colour'],
                s = ep_no_guests['marker_size'])
    
    plt.scatter(x = ep_has_guests['episode_number'],
                y = ep_has_guests['viewership_mil'], 
                c = ep_has_guests['colour'],
                s = ep_has_guests['marker_size'],
                marker = '*')
    
    
    plt.title('Popularity, Quality, and Guest Appearances on the Office')
    plt.xlabel('Episode Number')
    plt.ylabel('Viewership (Millions)')
    
    plt.show()
    
    
    # 2
    
    most_watched = office_episodes[office_episodes['viewership_mil'] == office_episodes['viewership_mil'].max()]['guest_stars']
    print(most_watched.head())
    top_star = 'Jessica Alba'