Skip to main content

Are gas prices affected by the sitting US President (Under Construction, testing html view)

Gas Prices in USA, historical analysis

This report is intended to review gas prices in the USA historically for comparison against various claims.

One such claim is that the sitting US President has a direct affect on gas prices.


Data from the EIA - US Energy Information Administration

This dataframe set GasPrices_eia_prices_1970_2022 comes from the EIA website as a downloadable CSV.

The EIA provides an FAQ for using the data, which includes instructions to download the CSV and for a reference Excel document that helps with conversion.

“To obtain the historical prices from the SEDS data, use the CSV file for All States—Prices. In the file, the code for gasoline prices for the transportation sector, in $/MMBtu, is: State Abbreviation (in column A) and MGACD (in column B). For example, the code for Alaska is AK—MGACD. Those prices, in $/MMBtu, can be converted to approximate dollars per gallon using the heat contents in Table A3 Petroleum consumption and fuel ethanol. There are 42 U.S. gallons in a barrel.”

The CSV is downloaded from > Section: Prices and expenditures > Subsection: All price and expenditure estimates > SubSubsection: Prices > 1970-2022 > XLSX CSV ZIP

The following shows the barrel prices falling sharply well before 2016’s national election, and remaining relatively stable until after the pandemic crashes of 2020.


```{python}

import pandas as pd

import matplotlib.pyplot as plt

# Path to the CSV file
file_path = 'C:/Users/dwolfe/Documents/Demo_Skills_SampleCode/Projects/National_Market_Markers/_dataframes/GasPrices_eia_prices_1970_2022.csv'

# Read the CSV file
df = pd.read_csv(file_path)

# Filter rows where 'MSN' column contains 'MGACD'
filtered_df = df[df['MSN'].str.contains('MGACD', case=False, na=False)]

# Calculate the average for each year for the filtered data
average_prices = filtered_df.iloc[:, 3:].mean()  # Assumes year data starts at the 4th column

# Create a line plot
plt.figure(figsize=(10, 5))  # Set the figure size
plt.plot(average_prices.index, average_prices.values, marker='o'# Plot the average prices
plt.title('Average Gas Prices Over Years for MGACD'# Add a title
plt.xlabel('Year'# Add x-axis label
plt.ylabel('Average Price'# Add y-axis label
plt.grid(True# Add a grid
plt.xticks(rotation=45# Rotate x-axis labels for better readability
plt.tight_layout()  # Adjust layout to make room for the rotated x-axis labels
plt.show()  # Display the plot

```




Data from Our World in Data

Our World in Data provides an international dataset to review.

This dataframe set GasePrices_OWD_crude-oil-prices.csv comes from the Our World in Data website as a downloadable CSV.

“Data Page: Oil price - Crude prices since 1861”, part of the following publication: Hannah Ritchie, Pablo Rosado and Max Roser (2023) - “Energy”. Data adapted from Energy Institute. Retrieved from https://ourworldindata.org/grapher/crude-oil-prices [online resource]

These international crude oil prices show the same trends, clearly indicating that the US President is unrelated to gas prices.




```{python}

import pandas as pd

import matplotlib.pyplot as plt

# Path to the CSV file
file_path = 'C:/Users/dwolfe/Documents/Demo_Skills_SampleCode/Projects/National_Market_Markers/_dataframes/GasPrices_owd_intl_1861_2023.csv'

# Read the CSV file
df = pd.read_csv(file_path)

# Display the first few rows to verify the data
print(df.head())

# Filter data for years 1970 to 2023
filtered_df = df[(df['Year'] >= 1970) & (df['Year'] <= 2023)]

# Plotting the filtered data
plt.figure(figsize=(12, 6))  # Set figure size
plt.plot(filtered_df['Year'], filtered_df['Oil price - Crude prices since 1861 (current US$)'], marker='o', linestyle='-')
plt.title('International Crude Oil Prices from 1970 to 2023')
plt.xlabel('Year')
plt.ylabel('Oil Price (current US$)')
plt.grid(True)
plt.xticks(rotation=45# Rotate x-axis labels for better readability
plt.tight_layout()  # Adjust layout
plt.show()  # Display the plot

  Entity      Code  Year  Oil price - Crude prices since 1861 (current US$)
0  World  OWID_WRL  1861                                           3.082002
1  World  OWID_WRL  1862                                           6.604290
2  World  OWID_WRL  1863                                          19.812870
3  World  OWID_WRL  1864                                          50.695790
4  World  OWID_WRL  1865                                          41.449783

```




Placeholder TBC…

Text

Popular posts from this blog

Learning Coding Fundamentals with Python and SQL

Learning Coding Fundamentals with Python and SQL Learning Coding Fundamentals with Python and SQL Darrell Wolfe ————————————————————— Disclaimers First It is not my intention to steal anyone’s thunder or copyrighted material. I do not believe these seven fundamentals are specific to Dr Hill (below), who was the initial inspiration to start this note file. That beings said, she has a particularly unique method of teaching, and I strongly recommend that if you are someone who needs a good teacher, she’s the one! This is my own process of learning. I take information from as many sources and teachers as possible, synthesis that material, and then practice it until I get good at it. Further, I like to take detailed notes so I can refer back to them when a particular tool starts getting rusty or dusty in my brain after disuse for a time. When I learned .rmd through my Google Data Analytics Certification, I

Becoming a Business Intelligene and Data Analyst

In order to learn SQL, here are the steps I'm using: I'm working through: W3 Schools SQL Tutorials   Coursera: Google Data Analytics Professional Certificate   YouTube's Alex the Analyst FREE " Data Analyst Bootcamp!! "  Google Searching to reference as many articles as I can find on various aspects. Using ChatGPT  to check my syntax and explain concepts to me, answering my questions like a tutor.  I've also joined/downloaded/am using: GitHub My Repository:  https://github.com/darrellwolfe/toposcreative SQL Quick Reference notes Trello SQL Server  Express: SQL Server 2022 Express is a free edition of SQL Server, ideal for development and production for desktop, web, and small server applications. Visual Studio 2022 Power BI Tableau &  Tableau Public TBC... Shalom  שָׁלוֹם : Live Long and Prosper! Darrell Wolfe Storyteller | Writer | Thinker | Consultant | Freelancer

Using INDIRECT to obtain a VLookup with a variable array reference

Case Study for using INDIRECT to obtain a VLookup with a variable array reference *For reference: I did not build this workbook, it came this way and I'm stuck with it until I can rebuild it correctly next year.* The Problem: I have a legacy workbook that I have to rebuild for next year, but his year I'm stuck with.  This workbook has at or near 100 tabs that need to be referenced on a Totals and Subtotals set of pages. There are a thousand better ways to do that, especially using Power Query and Power Pivot, but here we are. These sub-totals pages were for specific sub-sets of the data that could be found on any given page (Ex: One sub-totals page looks for all properties with a PC Code "548"). On the sub-totals pages, the previous builder had simply linked the cells to the various pages; resulting in over a thousand rows of data that looked like this: //='2001'!$A$20// However, when the end-user filtered the data on the origin pages, the data on the sub-tota