bolster.data_sources.nisra.stillbirths
NISRA Stillbirths and Infant Deaths Data Source.
Provides access to annual stillbirth and infant death statistics for Northern Ireland via the NISRA PxStat API, with geographic breakdowns by HSC Trust and Local Government District.
A stillbirth is defined as a baby born after 24 weeks of pregnancy that did not show any signs of life. Infant deaths are deaths of children under one year old.
- Original data source:
https://www.nisra.gov.uk/statistics/births-deaths-and-marriages/stillbirths
- PxStat matrices used:
SBAIDHSCT — annual stillbirths and infant deaths by HSC Trust (5 trusts + NI total)
SBAIDLGD — annual stillbirths and infant deaths by LGD (11 districts + NI total)
Update Frequency: Annual Geographic Coverage: Northern Ireland
Example
>>> from bolster.data_sources.nisra import stillbirths
>>> df = stillbirths.get_latest_stillbirths()
>>> sorted(df.columns.tolist())
['geography', 'geography_code', 'infant_deaths', 'stillbirths', 'year']
>>> # NI total stillbirths in 2024
>>> ni_2024 = df[(df["geography"] == "Northern Ireland") & (df["year"] == 2024)]
>>> bool(ni_2024["stillbirths"].iloc[0] > 0)
True
Attributes
Exceptions
Raised when stillbirths data fails validation. |
Functions
|
Get the latest annual stillbirth and infant death data for Northern Ireland. |
Validate stillbirths DataFrame for basic integrity. |
|
|
Filter stillbirths data to a specific year. |
Calculate annual NI totals and trends for stillbirths. |
Module Contents
- exception bolster.data_sources.nisra.stillbirths.NISRAValidationError[source]
Bases:
ExceptionRaised when stillbirths data fails validation.
Initialize self. See help(type(self)) for accurate signature.
- bolster.data_sources.nisra.stillbirths.get_latest_stillbirths(dimension='hsct', force_refresh=False)[source]
Get the latest annual stillbirth and infant death data for Northern Ireland.
Fetches annual data from the NISRA PxStat API for the chosen geographic breakdown. Returns the full time series available (HSCT from 1974, LGD from 2008).
Note
force_refreshis accepted for API compatibility but is ignored — the PxStat API is called directly with no local cache layer.- Parameters:
- Returns:
year: Registration year (int)geography_code: geography identifier codegeography: geography name labelstillbirths: Annual stillbirth count (int)infant_deaths: Annual infant death count (int)
- Return type:
DataFrame with columns
- Raises:
ValueError – If
dimensionis not a supported value.
Example
>>> df = get_latest_stillbirths() >>> sorted(df.columns.tolist()) ['geography', 'geography_code', 'infant_deaths', 'stillbirths', 'year'] >>> annual = df[df["geography"] == "Northern Ireland"].groupby("year")["stillbirths"].sum() >>> len(annual) > 0 True
- bolster.data_sources.nisra.stillbirths.validate_stillbirths_data(df)[source]
Validate stillbirths DataFrame for basic integrity.
- Parameters:
df (pandas.DataFrame) – DataFrame from
get_latest_stillbirths().- Returns:
True if validation passes.
- Raises:
NISRAValidationError – If validation fails.
- Return type:
Example
>>> import pandas as pd >>> validate_stillbirths_data(pd.DataFrame()) Traceback (most recent call last): ... bolster.data_sources.nisra.stillbirths.NISRAValidationError: DataFrame is empty
- bolster.data_sources.nisra.stillbirths.get_stillbirths_by_year(df, year)[source]
Filter stillbirths data to a specific year.
- Parameters:
df (pandas.DataFrame) – DataFrame from
get_latest_stillbirths().year (int) – Year to filter.
- Returns:
Filtered DataFrame.
- Return type:
Example
>>> df = get_latest_stillbirths() >>> df_2024 = get_stillbirths_by_year(df, 2024) >>> "stillbirths" in df_2024.columns True
- bolster.data_sources.nisra.stillbirths.get_annual_summary(df)[source]
Calculate annual NI totals and trends for stillbirths.
- Parameters:
df (pandas.DataFrame) – DataFrame from
get_latest_stillbirths().- Returns:
year,total_stillbirths,yoy_change,yoy_pct_change.- Return type:
DataFrame with columns
Example
>>> df = get_latest_stillbirths() >>> summary = get_annual_summary(df) >>> sorted(summary.columns.tolist()) ['total_stillbirths', 'year', 'yoy_change', 'yoy_pct_change']