bolster.data_sources.electricity_renewables
NI Electricity Consumption and Renewable Generation Statistics.
Published quarterly by the Department for the Economy (DfE) Northern Ireland in partnership with NISRA. Reports progress toward NI’s renewable electricity targets (80% of consumption from renewables by 2030 under the Climate Change Act (Northern Ireland) 2022).
- Data Source:
Interactive report (data embedded as base64 CSV): https://datavis.nisra.gov.uk/Economy/electricity-consumption-and-renewable-generation-report.html
The report embeds ten figures as base64-encoded UTF-16 LE CSV data-URIs. This module extracts and parses the four headline time series:
renewable_pct: Rolling 12-month renewable generation as a proportion of gross final electricity consumption (%) and monthly %.
consumption: Total consumption, renewable and non-renewable generation, and net imports (rolling 12-month GWh).
generation_by_technology: Rolling 12-month generation (GWh) by technology — wind, hydro, bioenergy, landfill gas, solar PV.
generation_monthly: Monthly renewable and non-renewable generation (GWh) going back to February 2018.
- Update Frequency:
Quarterly (March, June, September, December).
- Coverage:
Rolling 12-month figures: January 2019 – present. Monthly generation figures: February 2018 – present.
Example
>>> from bolster.data_sources import electricity_renewables
>>> data = electricity_renewables.get_latest_data()
>>> 'renewable_pct' in data
True
>>> 'renewable_pct_rolling_12m' in data['renewable_pct'].columns
True
>>> (data['renewable_pct']['renewable_pct_rolling_12m'] > 0).all()
True
Attributes
Exceptions
Electricity statistics page or data could not be retrieved. |
|
Electricity DataFrame failed validation checks. |
Functions
|
Download and parse the latest NI electricity and renewables statistics. |
|
Validate an electricity statistics DataFrame. |
Module Contents
- exception bolster.data_sources.electricity_renewables.ElectricityDataNotFoundError[source]
Bases:
ExceptionElectricity statistics page or data could not be retrieved.
Initialize self. See help(type(self)) for accurate signature.
- exception bolster.data_sources.electricity_renewables.ElectricityValidationError[source]
Bases:
ExceptionElectricity DataFrame failed validation checks.
Initialize self. See help(type(self)) for accurate signature.
- bolster.data_sources.electricity_renewables.get_latest_data(force_refresh=False)[source]
Download and parse the latest NI electricity and renewables statistics.
Returns four DataFrames covering the headline series from the DfE/NISRA quarterly electricity report.
- Parameters:
force_refresh (bool) – If
True, bypass the local cache and re-download.- Returns:
"renewable_pct"— rolling 12-month and monthly renewable generation as % of gross final consumption."consumption"— rolling 12-month total consumption, renewable generation, non-renewable generation, and net imports (GWh)."generation_by_technology"— rolling 12-month renewable generation (GWh) by technology: wind, hydro, bioenergy, landfill gas, solar PV."generation_monthly"— monthly renewable and non-renewable generation (GWh) going back to February 2018.
- Return type:
Dictionary with keys
- Raises:
ElectricityDataNotFoundError – If the datavis page cannot be fetched or no figure data is found in the HTML.
ElectricityValidationError – If the parsed data fails validation.
Example
>>> data = get_latest_data() >>> sorted(data.keys()) ['consumption', 'generation_by_technology', 'generation_monthly', 'renewable_pct'] >>> 'total_consumption_gwh' in data['consumption'].columns True
- bolster.data_sources.electricity_renewables.validate_data(df, key='renewable_pct')[source]
Validate an electricity statistics DataFrame.
- Parameters:
df (pandas.DataFrame) – DataFrame from
get_latest_data().key (str) – Which sub-dataset to validate (controls required-column check). One of
"renewable_pct","consumption","generation_by_technology","generation_monthly".
- Returns:
Trueif all checks pass.- Raises:
ElectricityValidationError – If the DataFrame is empty, missing required columns, has implausible values, or is too short.
- Return type:
Example
>>> data = get_latest_data() >>> validate_data(data['renewable_pct'], 'renewable_pct') True