Before / After Comparison#
Goal
Compare energy consumption before and after an optimization event to evaluate its impact.
Data Basis
Monthly energy consumption data (seasonal_monthly.csv) bundled with the pyedautils package. 10 years of monthly values.
Data Preparation#
import pandas as pd
from importlib import resources
data_path = resources.files("pyedautils") / "data" / "seasonal_monthly.csv"
df = pd.read_csv(data_path, sep=";")
df.head()
| timestamp | value | |
|---|---|---|
| 0 | 2010-01-01 | 19.000000 |
| 1 | 2010-02-01 | 19.642857 |
| 2 | 2010-03-01 | 17.032258 |
| 3 | 2010-04-01 | 8.633333 |
| 4 | 2010-05-01 | 0.870968 |
Visualization#
from pyedautils.plots import plot_seasonal_before_after
fig = plot_seasonal_before_after(
data=df,
date_optimization="2017-09-01",
title="Before/After Energy Optimization",
ylab="Mean daily energy [kWh/d]",
)
fig.show()
Customization
The plot_seasonal_before_after function accepts additional parameters:
date_optimization— The date that separates the “before” and “after” periods (format:"YYYY-MM-DD"). In this example,"2017-09-01"marks the optimization date.confidence— Controls the confidence interval shown around the seasonal means. Adjust to widen or narrow the uncertainty band.