Around the world, coal is slowly replaced with other forms of energy to help reduce the amount of greenhouse gases in Earth’s atmosphere. In the United States, the U.S. Energy Information Administration (EIA) collects energy information like coal production amounts over time. This story uses this time-series data to illustrate some of the TimeSeries functionality in the Wolfram Language.

To get started we need to access the data from the EIA. I wrote a simple function called UnitedStatesCoalProduction to access their data API and import coal production data by region:

UnitedStatesCoalProduction = ResourceFunction[
"user:arnoudb/DeployedResources/Function/UnitedStatesCoalProduction"]

This function is called with two arguments. The first argument specifies the region using a code like “KY” for “Kentucky”. The second argument is the API key which can be obtained from the EIA website. Details on how to do this are documented on the function reference documentation page. A typical way to call the function is as follows:

kentucky = UnitedStatesCoalProduction["KY",key]

This returns a TimeSeries object. In Wolfram notebooks, which always make heavy use of typeset display forms, it formats with a summary box:

Image for post

#computational-thinking #data-science #wolfram #programming #timeseries

Learning Wolfram: Working With TimeSeries
1.10 GEEK