What is the point?

Over the past few months, we have seen gasoline prices soar like never before, and it has caused a financial strain on many families. Therefore, this project will explore what are cost differences in owning a gasoline car vs. an electric car. This project also something I have been wanting to look into for two reasons. Firstly, as an avid car fan, I know that electric cars are more expensive than gasoline cars, so I am more curious about maintenance and refueling costs. Secondly, my family recently purchased a new gasoline car, and I thought it would be interesting to see how much an electric car would save my family in refueling and maintenance costs.

Gasoline Price Change Over Time

In this section, we will see the change in gasoline prices per gallon over time from 2012-Present, since electric cars were initially brought into the mainstream world around 2012 (Source: U.S. Bureau of Labor and Statistics). As mentioned before, gasoline prices are going up every day, so it is interesting to put it into perspective by looking at a graph. This graph should hopefully be able to show the rate gasoline prices are increasing by and how they have changed in the past compared to now.

To get this data, we need to scrape the US BLS website to get the table for gasoline prices, and then we can make a graph to show gas prices over time. To make life easier in both this section and the next section where we make the plot for charging costs, we can create a function that will scrape the website.

Here is a look at the Gasoline Prices Data scraped from the US BLS Website.
Year 1 2 3 4 5 6 7 8 9 10 11 12
2012 3.399 3.572 3.868 3.927 3.792 3.552 3.451 3.707 3.856 3.786 3.488 3.331
2013 3.351 3.693 3.735 3.590 3.623 3.633 3.628 3.600 3.556 3.375 3.251 3.277
2014 3.320 3.364 3.532 3.659 3.691 3.695 3.633 3.481 3.403 3.182 2.887 2.560
2015 2.110 2.249 2.483 2.485 2.775 2.832 2.832 2.679 2.394 2.289 2.185 2.060
2016 1.967 1.767 1.958 2.134 2.264 2.363 2.225 2.155 2.208 2.243 2.187 2.230
2017 2.351 2.299 2.323 2.418 2.386 2.337 2.281 2.374 2.630 2.484 2.548 2.459
2018 2.539 2.575 2.572 2.737 2.907 2.914 2.873 2.862 2.873 2.887 2.671 2.414
2019 2.289 2.353 2.564 2.835 2.901 2.752 2.776 2.655 2.630 2.673 2.620 2.587
2020 2.567 2.465 2.267 1.876 1.879 2.076 2.176 2.177 2.193 2.159 2.090 2.168
2021 2.326 2.496 2.791 2.839 2.972 3.154 3.233 3.255 3.265 3.385 3.482 3.408
2022 3.413 3.592 4.312 4.271 NA NA NA NA NA NA NA NA

As can be seen in the graph above, the gasoline prices have had a decline until 2016, then started to increase until early 2019, where the gasoline prices started to decrease once again until early 2020. Then, there was a rapid increase in gasoline prices until 2022. If we look carefully at the slope of the line that is showing the gas price increase after 2022, the rate is extremely high. This is also seen in the data where in February 2022 the price per gallon was at $3.592 and then in March 2022 the price per gallon increased to $4.312. An increase of this magnitude has never been seen before as shown in the plot above.

Now that we are able to see that gasoline prices are truly increasing at a rapid rate, let us check out how much it costs to charge per KWH. Since gallons and KWH are not comparable directly, we will convert them to price per month at a later point so they can be compared.

Charging Price Change Over Time

In this section, we will see the charging prices per KWH over time from 2012-Present since electric cars were initially brought into the mainstream world around 2012 (Source: U.S. Bureau of Labor and Statistics). As seen in the previous section, gasoline prices have been increasing at a rate that has never been seen before. Therefore, it is safe to make a hypothesis that electricity prices have also likely gone up albeit likely not at a similar rate.

The approach is the same as the previous section. First, we need to use the scraping function created previously to scrape the table from the US BLS website, and then we can create a plot to illustrate the change in electricity cost over time.

Here is a look at the Electricity Prices Data scraped from the US BLS Website.
Year 1 2 3 4 5 6 7 8 9 10 11 12
2012 0.128 0.128 0.127 0.127 0.129 0.135 0.133 0.133 0.133 0.128 0.127 0.127
2013 0.129 0.129 0.128 0.128 0.131 0.137 0.137 0.137 0.137 0.132 0.130 0.131
2014 0.134 0.134 0.135 0.131 0.136 0.143 0.143 0.143 0.141 0.136 0.134 0.135
2015 0.138 0.138 0.136 0.137 0.137 0.143 0.142 0.142 0.141 0.136 0.134 0.133
2016 0.134 0.134 0.134 0.134 0.133 0.138 0.139 0.139 0.139 0.134 0.131 0.133
2017 0.134 0.135 0.134 0.135 0.137 0.142 0.143 0.142 0.142 0.137 0.136 0.136
2018 0.135 0.135 0.135 0.134 0.136 0.139 0.139 0.139 0.138 0.136 0.134 0.135
2019 0.135 0.136 0.135 0.135 0.136 0.139 0.140 0.139 0.139 0.136 0.133 0.133
2020 0.134 0.134 0.134 0.133 0.134 0.137 0.137 0.137 0.137 0.135 0.136 0.136
2021 0.136 0.137 0.138 0.139 0.140 0.142 0.143 0.144 0.144 0.142 0.142 0.142
2022 0.147 0.148 0.150 0.151 NA NA NA NA NA NA NA NA

As can be seen in the graph above, over time, the charging price per KWH is increasing over time, and has increased dramatically from late 2020 to 2022. As we hypothesized before, we can see that the price of electricity has indeed increased at a staggering rate. The most recent increase can be seen from December 2021 to January 2022 where the price went from $0.142 to $0.147 within one month. Unlike gasoline prices though, there seem to be quite a bit of increases in electricity prices in a short time span.

Now that we can visualize the increases in both charging costs and gasoline costs, we can now understand that both are increasing at a rapid rate. Therefore, it is natural to wonder if it would be less expensive to own an electric car or a gasoline car during this time.

Gasoline and Electric Car Ranges

For both electric cars and gasoline cars, the range data is already given in the data set so we just need to take the average of all of the vehicles in the data to get the average range for both electric and gasoline cars. However, the thing we need to focus on is figuring out the average gallons in a car and the average KWH in each battery for each car to figure out how much gasoline/electricity needs to be refueled. Also notice that FFV means Flexible-fuel vehicle (Gasoline Vehicle) and EV means Electric Vehicle (Source: www.fueleconomy.gov).

To find the amount of gallons each gasoline car has, we can divide the range by the average MPG per vehicle. However, to find the MPG we need to convert the units from barrels per year to gallons per year. Then, since the dataset is based on a 15,000 mile drive per year, we can then divide 15,000 by the gallons per year to find the MPG for each vehicle. Then to find the average gallons we simply find the mean of all the gallon capacity each gasoline car has.

To find the amount of KWH each electric car has, we divide the combined KWH used for a 100 mile drive by 100 to find the amount of KWH used per mile, then we multiply that by the range of the car. This yields us the capacity of the battery for each vehicle. Similarly to the gasoline cars, we then find the mean capacity of the batteries to get the average capacity.

Here is a look at the Filtered Gasoline Vehicles Data.
range vehicle_gallons average_range average_gallons
238 14.16148 313.1669 14.43958
238 14.16148 313.1669 14.43958
238 14.16148 313.1669 14.43958
238 14.16148 313.1669 14.43958
344 19.10411 313.1669 14.43958
338 20.11168 313.1669 14.43958
307 18.26711 313.1669 14.43958
307 18.26711 313.1669 14.43958
344 19.10411 313.1669 14.43958
338 20.11168 313.1669 14.43958
Here is a look at the Filtered Electric Vehicles Data.
range vehicle_KW average_range average_KW
62 18.60 219.8247 75.6147
56 30.24 219.8247 75.6147
56 30.24 219.8247 75.6147
73 24.82 219.8247 75.6147
88 40.48 219.8247 75.6147
76 24.32 219.8247 75.6147
265 100.70 219.8247 75.6147
76 24.32 219.8247 75.6147
82 23.78 219.8247 75.6147
68 21.76 219.8247 75.6147

Here is a range comparison of both vehicles. It can be seen that the average gasoline car has a longer range than the average electric car. Therefore, it can be seen that a gasoline car is probably the better car for longer distances since there would be no need to refuel often. Furthermore, although this will not be discussed in this project, electric cars also take a longer time to charge. Therefore, if they were used for longer distance driving, it would add to the travel time, making it quite inconvenient. Therefore, electric cars are likely better used for local travel since there is no range problem in that case.

Although this graph shows that the average gasoline powered vehicle has a higher range, this does not tell the full story when it comes to cost.

Average Commuting Distance in the US

In this section we will take a look at the average round-trip commuting distance for anyone living in the United States outside of Alaska and Hawaii (Source: Street Light Data). For this section, the data we will look is a pdf from which we will extract a table of the 48 states which contains the median commute distance for one direction. We will have to multiply this by 2 to find the median commute distance for the round trip.

Unfortunately, the data from extracted from the pdf was not clean at all, and needed to be cleaned thoroughly before it became usable. Although the other data used previously required plenty of cleaning, this particular data was the least clean and was tough to fix to use especially since the complete table was not extracted so there was a need to manually enter in information for a few states.

Here is a look at the cleaned State Commute Data extracted from a PDF file.
State Median_Distance_Per_Day Median_Distance_State_Per_Year All_Average_Median_Distance_Per_Year
Alabama 15.6 5694 5259.042
Arizona 15.2 5548 5259.042
Arkansas 14.0 5110 5259.042
California 13.2 4818 5259.042
Colorado 13.8 5037 5259.042
Connecticut 13.0 4745 5259.042
Delaware 16.0 5840 5259.042
Florida 12.0 4380 5259.042
Georgia 14.8 5402 5259.042
Idaho 12.4 4526 5259.042

Cost of Refueling both Per Year and Over Time

In this section we will take a look at how much it would cost to refuel from 2012-2022 considering the average ranges, the fuel prices, and the average commuting distance for any given person. Now that we have cleaned all of the data required, we can start calculating refueling costs. This is the most interesting section since all of the cleaning and data that we worked on will be used in this section to give us information on the monetary benefits of either electric or gasoline vehicles.

To start off, we need to convert everything in terms of months since the pricing data we worked with in the first two section was given in months. After converting everything in terms of months, we need to combine the electricity and gasoline datasets which were separate before. After combining them, we can create two graphs which will show the cost of gasoline and electricity per month from 2012-2022.

Here is a look at the Monthly Data for Refueling.
atvType average_range commute_per_month avg_capacity_refilled_per_month refills_per_month
FFV 313.1669 438.2535 20.20711 1.399425
EV 219.8247 438.2535 150.74923 1.993650

Now that we have cleaned the data, let us create the price per month graphs for both gasoline and electricity to get the cost of both and to answer the question which one is less expensive.

As we can see, the graph shape is identical to the graphs from the first two sections, however, if we look closely at the Y-axis, it is evident that the numbers have changed to reflect the cost per month instead of cost per unit (KWH/gallons). It can be seen that gasoline is more expensive to refuel per month than electricity is since as of March 2022, it costs $87.133 to refuel an average gasoline car per month whereas it only costs $22.612 to refuel an average electric car per month. It seems that the difference in cost to refuel per month is not even a close contest as the average electric car is 4x less expensive to refuel per month.

Maintenance Savings Compared to an Average Gasoline Car

Finally, let us check the savings over 5 years compared to the average gasoline car. There are both negative and positive savings, where a positive savings shows the money you save and a negative savings shows a greater amount spent when compared to the average gasoline car. The maintenance of a car can include gasoline/electricity, repairs, oil changes, and other maintenance requirements for each respective type of vehicle.

As can be seen in the plot above, electric vehicles on average save you money over 5 years when compared to the average gasoline care while gasoline vehicles make you spend extra money over 5 years when compared to the average gasoline car. This can be attributed to the repair cost difference that a gasoline car would have since there are a lot more parts that could get damaged when compared to an electric car. Furthermore, as we discussed in the last section, electric cars also have an advantage in refueling costs. Considering the lack of repairs and the cheaper refueling costs, it is not very difficult to see why electric cars save you more money over an average gasoline car. However, what may seem interesting is how much the gasoline cars are not saving when compared to the average car. Since the car being compared is an average gasoline car, it can be assumed that the savings should be close to $0. However, it is important to remember that the average car taken into consideration here is likely a smaller reliable vehicle. This means that there are less parts that could go wrong since the engine is not complicated or very powerful, and overall it would not cost much to maintain. However, the complicated and more powerful parts found in other gasoline cars cause high repair costs.

Conclusion

In summary, it seems that on average, gasoline cars are more expensive to refuel per month than electric cars are (almost 4x as much!). Furthermore, electric vehicles also let you save money in maintenance when compared to gasoline cars due to the simplicity compared to a gasoline car. Therefore, from the data observed, electric cars seem to be the more cost-effective option over time since they are cheaper to maintain and are overall better for the environment. However, before one buys an electric car, there any many things to consider. Some important things to consider are: is your home able to have a charger installed, are you willing to put extra money upfront on the car to spend less over time, and are you willing to spend extra time on longer trips to recharge. Overall, regardless of which decision one may make on which vehicle to buy, it is based upon opinion, and there is no wrong answer. It is all up to one to decide which tradeoff is better for their lifestyle.