I'm back from EuroPython in Krakow, and while the news is full of current events from wildfires to inflation to the continuing war with Iran, a much-less modern story has been making headlines: The Odyssey, the new Christopher Nolan movie that critics are raving about. I haven't had a chance to see it yet, but I'm going to make an effort to do so in the coming weeks.
What's more, people are going to see the Odyssey in theaters, something that wasn't predicted during and after the covid-19 pandemic, which kept us all home and isolated, rather than in a crowded movie theater.
This got me wondering about how much the pandemic affected moviegoing, and how much theaters have bounced back since that time. And so, we'll examine data about movies, and particularly about movie theaters. Along the way, we'll look at which films and studios have done best, and what trends we're seeing.
Data and five questions
This week, we have data from two sources:
- First, we have a data dump of movie revenues per day in the United States from January 1st, 2000 through January 3rd, 2025. This data, from Box Office Mojo, was collected and assembled at the GitHub repo https://github.com/tjwaterman99/boxofficemojo-scraper. Information about this large
.csv.gzfile (https://github.com/tjwaterman99/boxofficemojo-scraper/releases/latest/download/revenues_per_day.csv.gz) are on that page. - Second, we'll retrieve more recent daily data from Box Office Mojo using the
boxoffice-apipackage (https://pypi.org/project/boxoffice-api/), whoseget_dailymethod reads Box Office Mojo's daily chart. The package can optionally enrich each film with metadata (poster, plot, director, cast) from the OMDb API (https://www.omdbapi.com/) if you supply a free key — but that isn't needed for the revenue data here.
Paid subscribers, both to Bamboo Weekly and to my LernerPython+data membership program (https://LernerPython.com) get all of the questions and answers, as well as downloadable data files, downloadable versions of my notebooks, one-click access to my notebooks, and invitations to monthly office hours.
Learning goals for this week include working with APIs, combining data, dates and times, cleaning data, and grouping.
Here are my five questions for this week. I'll be back tomorrow with my solutions and explanations:
- Download the daily movie revenue file, and open it in a Pandas data frame. Ensure that the
datecolumn is adatetimeand that it is the data frame's index. You can remove theidcolumn. Based on this data, which movie earned the most total in each year in the data set? Create a bar plot from this data, showing the highest-grossing movie's revenue in each year. If you're using Plotly (and I believe you should!), put the movie's title in the tooltip. - Create a line plot showing, for each year in the data set, the total revenue from all movies in the data set. Do you see the effect of the pandemic? According to this data, have we surpassed pre-pandemic movie revenue yet? (You can ask this again in question 5, if you want, after adding some more data.)