Whether or not you like football, the Super Bowl is a spectacle. There's a little something for everyone at your Super Bowl party. Drama in the form of blowouts, comebacks, and controversy for the sports fan. There are the ridiculously expensive ads, some hilarious, others gut-wrenching, thought-provoking, and weird. The half-time shows with the biggest musicians in the world, sometimes riding giant mechanical tigers or leaping from the roof of the stadium.
The dataset we'll use was scraped and polished from Wikipedia. It is made up of three CSV files, one with game data, one with TV data, and one with halftime musician data for 52 Super Bowls through 2018.
The Data
Three datasets have been provided, and summaries and previews of each are presented below.
1. halftime_musicians.csv
This dataset contains information about the musicians who performed during the halftime shows of various Super Bowl games. The structure is shown below, and it applies to all remaining files.
| Column | Description |
|---|---|
'super_bowl' | The Super Bowl number (e.g., 52 for Super Bowl LII). |
'musician' | The name of the musician or musical group that performed during the halftime show. |
'num_songs' | The number of songs performed by the musician or group during the halftime show. |
2. super_bowls.csv
This dataset provides details about each Super Bowl game, including the date, location, participating teams, and scores, including the points difference between the winning and losing team ('difference_pts').
3. tv.csv
This dataset contains television viewership statistics and advertisement costs related to each Super Bowl.
# Import libraries
import pandas as pd
import matplotlib.pyplot as plt# Load the CSV data into DataFrames
# Getting the Super Bowl data
super_bowls = pd.read_csv('datasets/super_bowls.csv')
super_bowls.head()# Getting the TV data
tv = pd.read_csv('datasets/tv.csv')
tv.head()# Getting the data about halftime musicians
halftime_musicians = pd.read_csv('datasets/halftime_musicians.csv')
halftime_musicians.head()# Start coding here
# Use as many cells as you need1 - Identifying the year with the highest viewership
# Finding the trend for viewership
plt.plot('super_bowl', 'avg_us_viewers', data=tv, label='Avg US Viewers')
plt.xlabel('Super Bowl')
plt.ylabel('Avg US Viewers')
plt.title('Average Number of US Viewers by Super Bowl')
plt.legend()
plt.show()viewership_increased = Truetv.sort_values('avg_us_viewers', ascending=False).head()2 - Determining the matches with point difference above 40
# Finding the point difference
difference = len(super_bowls[super_bowls['difference_pts'] > 40])
print(difference)super_bowls[super_bowls['difference_pts'] > 40]# Optional: plotting a histogram of point differences
plt.hist('difference_pts', data=super_bowls)
plt.xlabel('Point Difference')
plt.ylabel('Number of Super Bowls')
plt.title('Point Difference Histogram')
plt.show()