Data Science in Energy Management: A Python Example
Data science in energy management usually starts with a plain question: what is the generation mix, how is it changing, and can we forecast it? This article answers that with a small, real dataset, Iowa’s net electricity generation by source from 2001 to 2017, and tests whether a trend line can forecast it. It is a compact example of the workflow (pandas 3.0.5, NumPy 2.5.3), not a model of a real grid.

The data
The file is the iowa-electricity dataset from the open vega-datasets collection: 51 rows, one per year (2001 to 2017) and source (fossil fuels, nuclear, renewables). The file gives a net generation number per row but does not state units, so we report values as given and use shares for comparisons. It is one state and only three broad categories; it does not split wind from hydro or biomass.
import pandas as pd
d = pd.read_csv('iowa-electricity.csv', parse_dates=['year'])
d['y'] = d.year.dt.year
p = d.pivot(index='y', columns='source', values='net_generation')
share = p.div(p.sum(axis=1), axis=0) * 100
print(share.iloc[[0, -1]].round(1))The mix changed a lot
| Source | 2001 share | 2017 share | 2017 value / 2001 value |
|---|---|---|---|
| Fossil fuels | 87.0% | 51.9% | 0.83 |
| Nuclear | 9.5% | 9.2% | 1.35 |
| Renewables | 3.5% | 38.8% | 15.26 |
Renewables grew from 3.5% to 38.8% of generation, a 15-fold rise in absolute terms (1,437 to 21,933 in the file’s units). Fossil generation was still higher in 2011 (39,361) but fell to 29,329 by 2017, down 17% from 2001. Total generation grew from 40,651 to 56,476 (up 39%), so renewables did not just replace fossil fuels; some of the growth was new supply. Nuclear stayed roughly flat in share (9.5% to 9.2%), though its absolute output rose 35%.
Can a trend line forecast it?
Forecasting is a core energy-management task: operators plan around expected supply. We tested the simplest possible approach. We fitted a straight line to 2001 to 2012 for each source, then predicted 2013 to 2017, and compared it with simply repeating the 2012 value (“last value”).
| Source | Straight-line error (2013-17) | Last-value error | Actual 2017 vs line |
|---|---|---|---|
| Fossil fuels | 10,212 | 5,337 | 29,329 vs 43,178 |
| Nuclear | 372 | 658 | 5,214 vs 5,168 |
| Renewables | 3,586 | 4,290 | 21,933 vs 18,001 |
Results depend on the source. For fossil fuels the trend line was worse than ignoring the trend, because it extrapolated rising output while the real series turned down (43,178 predicted versus 29,329 actual in 2017). For nuclear and renewables the line did better than repeating the last value. The lesson for forecasting is that a trend fitted to 12 points cannot anticipate a policy or price shift, which is exactly what happened here. With only five test years per source, the comparison is suggestive, not conclusive.
What real energy data science adds
Utilities use hourly or sub-hourly data, weather, demand and prices, and models for load forecasting, wind and solar output and predictive maintenance. The techniques build on the basics shown here: careful aggregation, held-out tests and honest baselines. See time series analysis in Python, linear regression in Python and the factory example in data science in manufacturing. The pandas reshaping documentation covers the pivot used above.
Limits of this analysis
Annual data, one state, three categories, unspecified units, and a five-year forecast test. We cannot say what drove the changes; the file contains no information about policy, prices or demand.
FAQ
How is data science used in energy management?
For demand and load forecasting, forecasting wind and solar output, grid balancing and predictive maintenance. This article shows the basic analysis and forecast test on annual generation data.
What changed in Iowa’s electricity mix?
In this dataset, renewables rose from 3.5% to 38.8% of generation between 2001 and 2017, while fossil fuels fell from 87.0% to 51.9%.
Why did the trend line fail for fossil fuels?
It was fitted to a period of rising output, then output fell. Simple trend lines cannot anticipate such turns.
Can I download the data?
Yes, it is in the public vega-datasets repository linked above.
