Decomposed Profile#
Goal
Display daily electricity consumption profiles with the trend component removed, isolating the intra-day pattern from long-term drift.
Data Basis
Electricity data (ele_meter.csv) bundled with the pyedautils package: the mean electric power of a household in W per 15-minute interval (the 15-minute consumption in Wh × 4), for 2015.
Data Preparation#
import pandas as pd
from importlib import resources
data_path = resources.files("pyedautils") / "data" / "ele_meter.csv"
df = pd.read_csv(data_path, sep=";")
df.head()
| timestamp | value | |
|---|---|---|
| 0 | 2015-01-01 00:00:00 | 40.0 |
| 1 | 2015-01-01 00:15:00 | 32.0 |
| 2 | 2015-01-01 00:30:00 | 32.0 |
| 3 | 2015-01-01 00:45:00 | 34.0 |
| 4 | 2015-01-01 01:00:00 | 34.0 |
Visualization#
from pyedautils.plots import plot_daily_profiles
fig = plot_daily_profiles(
data=df,
method="decomposed",
loc_time_zone="Europe/Zurich",
title="Electricity - Decomposed Weekly Pattern",
ylab="Power deviation [W]",
)
fig.show()
Customization
The trend is a centered rolling mean over k rows. With 15-minute data the default k=672 is one week, so the weekly pattern stays in the profile and slower changes (seasons, holidays) are removed. A window shorter than a day would also remove the daily pattern.
fig = plot_daily_profiles(df, method="decomposed", loc_time_zone="Europe/Zurich", k=4 * 672) # 4-week trend