Thursday, May 23, 2019

Visualizing 4 Years of Car Fuel Usage with Tableau (Part 1)

One day I was traveling with a friend. We stopped off at a gas station and after fueling up their car they got back in and started writing something down in a little notepad. They were keeping track of their mileage over time so they could notice if their car was losing fuel efficiency. I thought this was interesting and when I bought a car in 2013 I decided I would keep track of this information myself. Additionally, my car had some extra features, so I decided I would keep track of a lot more information:
  • miles driven
  • price/gallon at pump
  • date
  • where I filled up (city name)
  • how much fuel my car said I used
  • how much fuel the pump said I put in my car
  • my average speed according to my car

I sold my car in 2017 and since then this spreadsheet has just been sitting there. I was traveling about 40 minutes one-way for work every day, so there are a lot of data points. Recently I’ve been looking into learning Tableau as a means of visualizing data and I figured this was as good a sample of data as any to cut my teeth on.

Cleaning the Data


The most obvious place to start is with the cost per gallon of fuel. So, plotting that up let's take a look:


Little known fact: 2014 always dreamed of being a unicorn.
Price per gallon for nearly every refueling over approximately 4 years.
I can hear you thinking “what’s that spike around the summer of 2014?” Going back to the data it’s immediately apparent that this was during a time I was traveling cross-country. Because the cost of fuel appears to fluctuate noticeably depending on where I bought it from, I can interpret this as if these prices are drawn from a different distribution than the values from my home town.




There are other instances of this (especially in the summer and around winter when I usually travel to visit family). Fortunately, I can place some constraints on the data and remove all points that aren't associated with my hometown. I did this by first computing the latitude and longitude of each city where I fueled up in. Then I applied filters to select only those latitudes and longitudes around my hometown.

2014 eventually got over it's "mohawk" phase.
Price per gallon for fuel restricted to only refuelings in my hometown

That clears things up nicely! There are a few features in this distribution, most noticeable is the difference between winter and summer. 

Next Up

In the next post, I'll dive a little deeper into the data and analyze the actual fuel trends that appear in the above image.

  • Part 2: Seasonal trends in fuel prices

No comments:

Post a Comment

Visualizing 4 Years of Car Fuel Usage with Tableau (Appendix)

This post is an appendix to the "Visualizing 4 Years of Car Fuel Usage with Tableau" series. Here I want to outline how I've u...