bolster.data_sources.nisra.index_of_production
NISRA Index of Production (IOP) for Northern Ireland.
Provides quarterly index of manufacturing and production output, comparing Northern Ireland against the UK average. Base year 2020=100.
Sectors covered (with approximate weights): - Manufacturing (78.8%): food, drink, tobacco, textiles, chemicals, machinery, etc. - Electricity, gas, steam (11.0%) - Water supply and waste management (8.4%) - Mining and quarrying (1.8%)
- Data Source:
Statistics page: https://www.nisra.gov.uk/statistics/economic-output/index-production The module scrapes this page to find the latest quarterly publication, then downloads the Excel tables file.
Update Frequency: Quarterly (published ~3 months after reference quarter) Geographic Coverage: Northern Ireland and UK comparison Base Year: 2020=100
Example
>>> from bolster.data_sources.nisra import index_of_production as iop
>>> df = iop.get_latest_iop()
>>> 'ni_index' in df.columns
True
Attributes
Functions
Scrape the IOP statistics page to find the latest quarterly Excel file. |
|
|
Parse IOP Excel tables file into long-format DataFrame. |
|
Get the latest NI Index of Production quarterly series. |
Validate IOP DataFrame for basic integrity. |
|
|
Filter IOP data to a specific year. |
|
Filter IOP data to a specific quarter. |
|
Calculate summary statistics for a period of IOP data. |
|
Calculate quarter-on-quarter and year-on-year growth rates. |
Module Contents
- bolster.data_sources.nisra.index_of_production.IOP_STATS_URL = 'https://www.nisra.gov.uk/statistics/economic-output/index-production'[source]
- bolster.data_sources.nisra.index_of_production.get_latest_iop_publication_url()[source]
Scrape the IOP statistics page to find the latest quarterly Excel file.
- bolster.data_sources.nisra.index_of_production.parse_iop_file(file_path)[source]
Parse IOP Excel tables file into long-format DataFrame.
Reads Table_1 which contains the headline NI and UK index series.
- Parameters:
file_path (str | pathlib.Path) – Path to downloaded IOP tables Excel file
- Returns:
date: Timestamp (first day of quarter)
year: int
quarter: int (1-4)
quarter_label: str (e.g. “Q1 2025”)
ni_index: float (NI Index of Production, 2020=100)
uk_index: float (UK Index of Production, 2020=100)
- Return type:
DataFrame with columns
- Raises:
NISRAValidationError – If file structure is unexpected
- bolster.data_sources.nisra.index_of_production.get_latest_iop(force_refresh=False)[source]
Get the latest NI Index of Production quarterly series.
- Parameters:
force_refresh (bool) – If True, bypass cache and download fresh data
- Returns:
date, year, quarter, quarter_label, ni_index, uk_index (base year 2020=100)
- Return type:
DataFrame with columns
- Raises:
NISRADataNotFoundError – If latest publication cannot be found
NISRAValidationError – If file structure is unexpected
Example
>>> df = get_latest_iop() >>> 'ni_index' in df.columns True
- bolster.data_sources.nisra.index_of_production.validate_iop_data(df)[source]
Validate IOP DataFrame for basic integrity.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_iop()
- Returns:
True if validation passes
- Raises:
NISRAValidationError – If validation fails
- Return type:
- bolster.data_sources.nisra.index_of_production.get_iop_by_year(df, year)[source]
Filter IOP data to a specific year.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_iop()
year (int) – Year to filter
- Returns:
Filtered DataFrame (up to 4 quarters)
- Return type:
Example
>>> df = get_latest_iop() >>> df_2024 = get_iop_by_year(df, 2024) >>> len(df_2024) <= 4 True
- bolster.data_sources.nisra.index_of_production.get_iop_by_quarter(df, quarter, year)[source]
Filter IOP data to a specific quarter.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_iop()
quarter (int) – Quarter number (1-4)
year (int) – Year
- Returns:
Filtered DataFrame (single row)
- Return type:
Example
>>> df = get_latest_iop() >>> q1_2024 = get_iop_by_quarter(df, 1, 2024) >>> len(q1_2024) == 1 True
- bolster.data_sources.nisra.index_of_production.get_iop_summary_statistics(df, start_year=None, end_year=None)[source]
Calculate summary statistics for a period of IOP data.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_iop()
start_year (int | None) – Optional start year filter (inclusive)
end_year (int | None) – Optional end year filter (inclusive)
- Returns:
period, ni_mean, ni_min, ni_max, uk_mean, uk_min, uk_max, quarters_count
- Return type:
Dictionary with keys
Example
>>> df = get_latest_iop() >>> stats = get_iop_summary_statistics(df, start_year=2020) >>> 'ni_mean' in stats True
- bolster.data_sources.nisra.index_of_production.get_iop_growth(df)[source]
Calculate quarter-on-quarter and year-on-year growth rates.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_iop()
- Returns:
ni_qoq: NI quarter-on-quarter % change
ni_yoy: NI year-on-year % change
uk_qoq: UK quarter-on-quarter % change
uk_yoy: UK year-on-year % change
- Return type:
DataFrame with additional columns
Example
>>> df = get_latest_iop() >>> growth = get_iop_growth(df) >>> 'ni_yoy' in growth.columns True