1. Welcome!
.
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:
- 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).
# Use this cell to begin your analysis, and add as many as you would like!
import matplotlib.pyplot as plt
import numpy as np
import pandas as pdoffice_data = pd.read_csv('datasets/office_episodes.csv')
office_data.head()episode_number = office_data[['episode_number']]
viewership = office_data[['viewership_mil']]
has_guests = office_data['has_guests']
ratings = office_data['scaled_ratings']
color_mapping = []
for rating in ratings:
if rating < 0.25:
color_mapping.append('red')
elif rating < 0.5:
color_mapping.append("orange")
elif rating < 0.75:
color_mapping.append("lightgreen")
else:
color_mapping.append("darkgreen")
size_mapping = []
for item in has_guests:
if item == True:
size_mapping.append(250)
else:
size_mapping.append(25)
fig = plt.figure()
plt.scatter(episode_number, viewership, c=color_mapping, s=size_mapping)
plt.title("Popularity, Quality, and Guest Appearances on the Office")
plt.xlabel("Episode Number")
plt.ylabel("Viewership (Millions)")
plt.show()max_viewership_row_index = office_data['viewership_mil'].idxmax()
max_viewership_row = office_data.iloc[max_viewership_row_index]
top_star = 'Jessica Alba'
print(top_star)