BW #83: Gasoline prices
Americans pay close attention to gas prices, and complain bitterly about them – even when those prices are far below what people in less-wealthy countries are paying. Kai Ryssdal, the Marketplace (https://marketplace.org/) anchor, has sometimes said that people are sensitive to the price of gas not just because they buy it so often, but also because the prices are displayed in huge numbers everywhere they go. It doesn't help that when I visited the US in May, I saw many fewer electric vehicles than at home in Israel or when I travel to Europe.
Gas prices are a particularly big deal right now, because of the looming presidential election. Many Americans appear to see gas prices as a proxy for the status of the economy, not to mention the cost of living and inflation. If gas prices have gone down recently, then that's seen as a positive sign for the economy, and helps the incumbent. And if gas prices have gone up? Then people believe that the economy (and inflation in particular) are out of control, which helps the challenger. (Kamala Harris is closer to incumbent status, even if she's not the sitting president.)
Just today, the New York Times reported that gas prices have declined since last year (https://www.nytimes.com/2024/09/11/business/gas-prices.html?unlocked_article_code=1.J04.b2Z9.5bY7k7zsD7_f&smid=url-share). That's not enough to change the election all by itself, but it could be a factor favoring Harris if the prices remain low.
This week, we'll look at the history of US gas prices. We'll see where they stand now, and how much they have changed over the years. We'll also see if there are seasonal or regional differences.
Moreover, we'll produce some nice-looking reports using the Great Tables project (https://pypi.org/project/great-tables/), a project that I've heard more and more about over the last few months, including on the Real Python podcast (https://realpython.com/podcasts/rpp/214/). Great Tables makes it easy to spruce up your data in a variety of ways, making it as attractive as it is informative.
Data and six questions
Our data comes from the US Energy Information Administration, which tracks (among other things) the price of gasoline of different types, and in different areas of the country. You can download the data from their main report page, which is updated weekly:
https://www.eia.gov/petroleum/gasdiesel/
The data itself is in an Excel spreadsheet you can download by clicking on the "full history XLS" link next to the "regular gasoline prices" table. Or you can download it directly from here:
https://www.eia.gov/petroleum/gasdiesel/xls/pswrgvwall.xls
This week's learning goals include working with Excel files, with datetime data, resampling, plotting, and (as mentioned) using the Great Tables library.
Here are this week's six tasks and questions. I'll be back tomorrow with my solutions, including the Jupyter notebook I used to solve these questions:
- Create a data frame from the "Data 1" tab in the Excel file. The index should be the "Date" column. Shorten the other column names by removing the text that's common to them.
- In which region of the US have gas prices been, on average, the highest since 2000?