bolster.data_sources.nisra.index_of_services
NISRA Index of Services (IOS) for Northern Ireland.
Provides quarterly index of services sector output, comparing Northern Ireland against the UK average. Base year 2020=100.
Services sectors covered: - Wholesale and retail trade; repair of motor vehicles - Accommodation and food service activities - Information and communication - Financial and insurance activities - Professional, scientific and technical activities - Public administration and defence - Education - Human health and social work activities - Other services
- Data Source:
Statistics page: https://www.nisra.gov.uk/statistics/economic-output/index-services 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_services as ios
>>> df = ios.get_latest_ios()
>>> 'ni_index' in df.columns
True
>>> growth = ios.get_ios_growth(df)
>>> 'ni_yoy' in growth.columns
True
Attributes
Functions
Scrape the IOS statistics page to find the latest quarterly Excel file. |
|
|
Parse IOS Excel tables file into long-format DataFrame. |
|
Get the latest NI Index of Services quarterly series. |
Validate IOS DataFrame for basic integrity. |
|
|
Filter IOS data to a specific year. |
|
Filter IOS data to a specific quarter. |
|
Calculate summary statistics for a period of IOS data. |
|
Calculate quarter-on-quarter and year-on-year growth rates. |
Module Contents
- bolster.data_sources.nisra.index_of_services.IOS_STATS_URL = 'https://www.nisra.gov.uk/statistics/economic-output/index-services'[source]
- bolster.data_sources.nisra.index_of_services.get_latest_ios_publication_url()[source]
Scrape the IOS statistics page to find the latest quarterly Excel file.
- bolster.data_sources.nisra.index_of_services.parse_ios_file(file_path)[source]
Parse IOS Excel tables file into long-format DataFrame.
Reads Table_1_1 which contains the headline NI and UK services index series.
- Parameters:
file_path (str | pathlib.Path) – Path to downloaded IOS 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 Services, 2020=100)
uk_index: float (UK Index of Services, 2020=100)
- Return type:
DataFrame with columns
- Raises:
NISRAValidationError – If file structure is unexpected
- bolster.data_sources.nisra.index_of_services.get_latest_ios(force_refresh=False)[source]
Get the latest NI Index of Services 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_ios() >>> 'ni_index' in df.columns True
- bolster.data_sources.nisra.index_of_services.validate_ios_data(df)[source]
Validate IOS DataFrame for basic integrity.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_ios()
- Returns:
True if validation passes
- Raises:
NISRAValidationError – If validation fails
- Return type:
- bolster.data_sources.nisra.index_of_services.get_ios_by_year(df, year)[source]
Filter IOS data to a specific year.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_ios()
year (int) – Year to filter
- Returns:
Filtered DataFrame (up to 4 quarters)
- Return type:
Example
>>> df = get_latest_ios() >>> df_2024 = get_ios_by_year(df, 2024) >>> len(df_2024) <= 4 True
- bolster.data_sources.nisra.index_of_services.get_ios_by_quarter(df, quarter, year)[source]
Filter IOS data to a specific quarter.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_ios()
quarter (int) – Quarter number (1-4)
year (int) – Year
- Returns:
Filtered DataFrame (single row)
- Return type:
Example
>>> df = get_latest_ios() >>> q1_2024 = get_ios_by_quarter(df, 1, 2024) >>> len(q1_2024) == 1 True
- bolster.data_sources.nisra.index_of_services.get_ios_summary_statistics(df, start_year=None, end_year=None)[source]
Calculate summary statistics for a period of IOS data.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_ios()
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_ios() >>> stats = get_ios_summary_statistics(df, start_year=2020) >>> 'ni_mean' in stats True
- bolster.data_sources.nisra.index_of_services.get_ios_growth(df)[source]
Calculate quarter-on-quarter and year-on-year growth rates.
- Parameters:
df (pandas.DataFrame) – DataFrame from get_latest_ios()
- 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_ios() >>> growth = get_ios_growth(df) >>> 'ni_yoy' in growth.columns True