data_processing
frequenz.lib.notebooks.reporting.data_processing ¤
Microgrid Reporting DataFrame Construction.
This module constructs normalized energy-report DataFrames from raw microgrid telemetry by harmonizing timestamps and column naming, enriching PV flows, adding grid KPIs, and surfacing component-specific metrics used downstream for dashboards.
Functions:¤
- Energy Report DataFrame Construction
create_energy_report_df: Builds a normalized energy report table with unified naming, timezone conversion, grid import calculation, and component renaming based on a MicrogridConfig.create_battery_usecase_df: Builds the standardized battery-usecase table used by the reporting plot helpers.
Usage:¤
Use create_energy_report_df() inside reporting pipelines or notebooks to transform raw microgrid exports into localized, labeled, and analysis-ready tables for KPIs, dashboards, and stakeholder reporting.
Classes¤
Functions:¤
frequenz.lib.notebooks.reporting.data_processing.create_battery_usecase_df ¤
create_battery_usecase_df(
energy_report_df: DataFrame,
*,
timestamp_col: str = "timestamp",
consumption_col: str = "mid_consumption",
grid_consumption_col: str = "grid_consumption",
battery_col: str = "battery_power_flow",
pv_col: str | None = "pv_asset_production",
chp_col: str | None = "chp_asset_production",
wind_col: str | None = "wind_asset_production"
) -> DataFrame
Create a standardized battery-usecase DataFrame.
Selects the battery-usecase input columns from the source DataFrame, renames them to the standardized reporting schema, keeps the site consumption baseline used for plotting, computes reference peak lines, and splits battery power flow into charging and discharging series.
| PARAMETER | DESCRIPTION |
|---|---|
energy_report_df
|
Reporting DataFrame containing the source columns for timestamp, consumption, grid consumption, and battery power flow.
TYPE:
|
timestamp_col
|
Column name in
TYPE:
|
consumption_col
|
Column name in
TYPE:
|
grid_consumption_col
|
Column name in
TYPE:
|
battery_col
|
Column name in
TYPE:
|
pv_col
|
Optional column name in
TYPE:
|
chp_col
|
Optional column name in
TYPE:
|
wind_col
|
Optional column name in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
The battery-usecase DataFrame with derived helper columns for plotting |
DataFrame
|
and analysis. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If required columns are missing from the input DataFrame. |
Source code in src/frequenz/lib/notebooks/reporting/data_processing.py
frequenz.lib.notebooks.reporting.data_processing.create_energy_report_df ¤
create_energy_report_df(
df: DataFrame,
component_types: list[str],
mcfg: MicrogridConfig,
mapper: ColumnMapper,
*,
tz_name: str = "Europe/Berlin",
assume_tz: str = "UTC",
fill_missing_values: bool = True,
aggregated_component_config: (
AggregatedComponentConfig | None
) = None
) -> DataFrame
Create a normalized Energy Report DataFrame with selected columns.
Makes a copy of the input, converts the timestamp column to the configured timezone, renames standard columns to unified names, adds the net import column, renames numeric component IDs to labeled names, and returns a reduced DataFrame containing only relevant columns.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
Raw input table containing energy data.
TYPE:
|
component_types
|
Component types to include in the Energy Report DataFrame
(e.g., |
mcfg
|
Configuration object used to resolve component IDs.
TYPE:
|
mapper
|
Column Mapper object to standardize the column names.
TYPE:
|
tz_name
|
Target timezone name for timestamp conversion (default: "Europe/Berlin").
TYPE:
|
assume_tz
|
Timezone to assume for naive datetimes before conversion (default: "UTC").
TYPE:
|
fill_missing_values
|
Whether to fill missing aggregate component columns from per-component sums (default: True).
TYPE:
|
aggregated_component_config
|
Optional mapping of component types to aggregated
column metadata used when filling missing aggregates. Defaults to the shared
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
The Energy Report DataFrame with standardized and selected columns. |
Notes
Component IDs are renamed to labeled names via label_component_columns().
Source code in src/frequenz/lib/notebooks/reporting/data_processing.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |