I first saw It's Always Sunny in Philadelphia (IASIP) over 10 years ago and thought, "wow, this will be canceled tomorrow." I was wrong. Season 14 will tie IASIP with The Adventures of Ozzie and Harriet as the longest-running live-action sitcom in American TV history. What has made the show endure? What are some of the most popular aspects of the show? I took a quantitative approach to these questions and along the way confirmed some biases (score!).
I gathered the IMDB ratings, cast / crew info, and data from Fandom for each episode using SeekWell. Here's an outline of that process:
- Downloaded IMDB CSV's
- Imported them via Pandas to SeekWell
- Scraped Fandom BeautifulSoup
- Extracted features from soup and merged with IMDB data on episode number
- Sent DataFrames to Google Sheets using SeekWell
Now that we have a clean dataset, let's answer a few questions.
How has the show done over time?
IASIP is consistently popular. Although viewers rated season 7 episodes slightly lower and season 13 saw a slump in ratings, every season has an average rating of at least 8. The series average is 8.26.
Does the time of day / day of week effect the popularity of an episode?
Most IASIP episodes start with two titles showing something like "2:30 PM" → "On a Thursday".
Fandom had this data for about 50% of the episodes. Since Netflix removed IASIP (could I put Hulu on our corporate card?), I had no way to fill in the missing data. A few observations:
- Only one episode started on a Sunday, "How Mac Got Fat" (Season 7, Episode 10), which starts with Mac giving a confessional
- Wednesday had the lowest average rating (aside from Sunday)
- Monday and Friday had the highest average rating
- Very few episodes start at night or during the evening
- 50% start in the morning (5 to 11 AM)
- Night and evening episodes have a slightly higher rating
- 14% of episodes start on Monday morning
- Saturday morning had the highest average rating of 8.7 (excluding cells with < 3 episodes)
What are the most popular motifs?
Most of the "categories" from Fandom are literary motifs. I gathered these for each episode and ranked the categories by the average ratings for episodes where the motif appeared. Here are the top 5:
- Musical episodes had an average rating of 8.6 over 5 episodes
- Dennis' Range Rover plays a major role in 6 episodes, which had an average rating of 8.52
- Charlie work is any work the rest of the gang doesn't want to do at Paddy's (e.g. clean toilets). Episodes concerning Charlie Work had an average rating of 8.46 (5 episodes)
- The gang regularly forms "alliances" at the start of each episode. Alliances in IASIP are fickle, often changing mid-episode. When Charlie and Dee team up, there was a rating of 8.41 (8 episodes). This data is missing for most episodes. I think this would have been more relevant if I had it for every episode.
- "Bottle episodes", which take place in one location (e.g. Paddy's Pub), had a rating of 8.41 (9 episodes).
Who are the most popular characters / contributors?
I was surprised here. I expected a few recurring characters like Rickety Cricket or the McPoyles to a have higher average episode rating, but that wasn't the case. Uncle Jack (Andrew Friedman) was the only character that made the top 5. However, writers and producers were capable of generating higher averages.
What would the perfect IASIP episode look like?
Pulling it all together, I built a Linear Regression and a Random Forest model to predict the rating based on 190 variables (e.g. writers, directors, actors, motifs, etc.). It was easy to come up with combinations that would score a perfect 10 with the regression model (in fact, one combination scored a 42), but this was much tougher with the Random Forest. The highest a random episode scored was a little under 9. Here's one "perfect" episode:
According to the regression model, this episode would get a 13.2 IMDB rating and would probably win an Emmy. My message to the gang: this episode "is right thing to do, so do".
Shameless plug: If you're a data person, check out our app at seekwell.io. It's a blazing fast SQL and Python IDE that's tightly integrated with Google Sheets. It comes with a free shared code repository for your team. We think of it as a Swiss Army knife for data teams.