Skip to content

pycensus.census.countries.usa.fuel_prices

US retail motor-gasoline prices by state and year (EIA State Energy Data System, SEDS).

Series MGTCD: motor gasoline price, transportation sector, dollars per million Btu, annual, 1970 onward, every state + DC (+ US). Converted to dollars per gallon with EIA's heat content of motor gasoline (5.053 MMBtu per barrel / 42 gallons = 0.1203 MMBtu per gallon). Downloaded once (no API key) into <cache>/eia_seds/pr_all.csv.

from pycensus.census.countries.usa.fuel_prices import gasoline_prices, gasoline_price_mean
gasoline_prices()                                  # DataFrame: state (USPS), year, usd_per_gallon
gasoline_price_mean(2019, 2023)                    # {state: mean $/gal over 2019-2023} -- e.g. an ACS 5-year period

gasoline_prices(cache_dir=None)

Long table: state (USPS code, 'US' = national), year (int), usd_per_gallon.

Parameters:

Name Type Description Default
cache_dir Optional[str]

Cache folder; None = the pycensus cache.

None

gasoline_price_mean(first_year, last_year, cache_dir=None)

{state: mean $/gal over [first_year, last_year]} (an ACS 5-year estimate's period, e.g. 2019-2023). Years past the last published one use the latest year available.

Parameters:

Name Type Description Default
first_year int

First year.

required
last_year int

Last year.

required
cache_dir Optional[str]

Cache folder; None = the pycensus cache.

None