bolster.data_sources.dva

DVA (Driver & Vehicle Agency) Monthly Tests Statistics Module.

This module provides access to Northern Ireland’s Driver & Vehicle Agency monthly test statistics, including vehicle tests, driver tests, and theory tests.

Data is published monthly by the Department for Infrastructure (DfI) Northern Ireland.

Data Coverage:
  • Vehicle Tests (Full & Retests): April 2014 - Present

  • Driver Tests: April 2014 - Present

  • Theory Tests: April 2014 - Present

  • Test breakdowns by category and test centre

Data Source: Department for Infrastructure Northern Ireland provides Driver & Vehicle Agency statistics through their publications portal at https://www.infrastructure-ni.gov.uk/publications?f%5B0%5D=type%3Astatisticalreports. The DVA publishes monthly test statistics covering vehicle tests, driver tests, and theory tests conducted across Northern Ireland, providing comprehensive data on driving and vehicle testing performance.

Update Frequency: Monthly publications are released covering the previous month’s test statistics. DVA data is published by the Department for Infrastructure Analytics Branch approximately 4-6 weeks after the reference month ends, providing consistent monthly updates on driving test performance and vehicle testing statistics across Northern Ireland.

Publication Details:
  • Published by: Department for Infrastructure (DfI) - Analytics Branch

  • Data Source: DVA Business & Regulatory Statistics

Example

>>> from bolster.data_sources import dva
>>> # Get latest vehicle test statistics
>>> df = dva.get_latest_vehicle_tests()
>>> 'tests_conducted' in df.columns
True
>>> # Get latest driver test statistics
>>> df = dva.get_latest_driver_tests()
>>> len(df) > 0
True
>>> # Get latest theory test statistics
>>> df = dva.get_latest_theory_tests()
>>> len(df) > 0
True
>>> # Get all test types combined
>>> data = dva.get_latest_all_tests()
>>> sorted(data.keys())
['driver', 'theory', 'vehicle']

Attributes

logger

CACHE_DIR

DVA_PUBLICATIONS_URL

DVA_SEARCH_TERM

Exceptions

DVADataError

Base exception for DVA data errors.

DVADataNotFoundError

Data file not available.

Functions

get_latest_dva_publication_url()

Get the URL of the latest DVA Monthly Tests publication.

parse_vehicle_tests(file_path)

Parse DVA vehicle tests data from Excel file.

parse_driver_tests(file_path)

Parse DVA driver tests data from Excel file.

parse_theory_tests(file_path)

Parse DVA theory tests data from Excel file.

get_latest_vehicle_tests([force_refresh])

Get the latest vehicle test statistics.

get_latest_driver_tests([force_refresh])

Get the latest driver test statistics.

get_latest_theory_tests([force_refresh])

Get the latest theory test statistics.

get_latest_all_tests([force_refresh])

Get all test types (vehicle, driver, theory) from the latest publication.

get_tests_by_year(df, year)

Filter test data for a specific year.

get_tests_by_month(df, month, year)

Get test data for a specific month and year.

calculate_growth_rates(df[, periods])

Calculate year-on-year growth rates for test statistics.

get_summary_statistics(df[, start_year, end_year])

Calculate summary statistics for test data.

validate_dva_test_data(df)

Validate DVA test statistics data integrity.

Module Contents

bolster.data_sources.dva.logger[source]
bolster.data_sources.dva.CACHE_DIR[source]
bolster.data_sources.dva.DVA_PUBLICATIONS_URL = 'https://www.infrastructure-ni.gov.uk/publications/type/statistics'[source]
bolster.data_sources.dva.DVA_SEARCH_TERM = 'driver-and-vehicle-agency-monthly-tests-conducted'[source]
exception bolster.data_sources.dva.DVADataError[source]

Bases: Exception

Base exception for DVA data errors.

Initialize self. See help(type(self)) for accurate signature.

exception bolster.data_sources.dva.DVADataNotFoundError[source]

Bases: DVADataError

Data file not available.

Initialize self. See help(type(self)) for accurate signature.

bolster.data_sources.dva.get_latest_dva_publication_url()[source]

Get the URL of the latest DVA Monthly Tests publication.

Attempts to find the most recent DVA monthly tests statistics publication by trying recent months in reverse order.

Returns:

Tuple of (excel_url, publication_title, publication_date)

Raises:

DVADataNotFoundError – If unable to find any recent publication

Return type:

tuple[str, str, datetime.datetime]

Example

>>> url, title, pub_date = get_latest_dva_publication_url()
>>> url.startswith('https://')
True
bolster.data_sources.dva.parse_vehicle_tests(file_path)[source]

Parse DVA vehicle tests data from Excel file.

Extracts full vehicle tests conducted from Table 1.1a.

Parameters:

file_path (str | pathlib.Path) – Path to the DVA Excel file

Returns:

  • date: datetime (first day of month)

  • year: int

  • month: str (month name)

  • tests_conducted: int (full tests conducted)

  • rolling_12_month_total: int (optional, rolling 12-month sum)

Return type:

DataFrame with columns

Example

>>> url, _, _ = get_latest_dva_publication_url()
>>> path = _download_file(url)
>>> df = parse_vehicle_tests(path)
>>> 'tests_conducted' in df.columns
True
>>> len(df) > 0
True
bolster.data_sources.dva.parse_driver_tests(file_path)[source]

Parse DVA driver tests data from Excel file.

Extracts driver tests conducted from Table 2.1.

Parameters:

file_path (str | pathlib.Path) – Path to the DVA Excel file

Returns:

  • date: datetime (first day of month)

  • year: int

  • month: str (month name)

  • tests_conducted: int (driver tests conducted)

  • rolling_12_month_total: int (optional, rolling 12-month sum)

Return type:

DataFrame with columns

Example

>>> url, _, _ = get_latest_dva_publication_url()
>>> path = _download_file(url)
>>> df = parse_driver_tests(path)
>>> 'tests_conducted' in df.columns
True
>>> len(df) > 0
True
bolster.data_sources.dva.parse_theory_tests(file_path)[source]

Parse DVA theory tests data from Excel file.

Extracts theory tests conducted from Table 3.1.

Parameters:

file_path (str | pathlib.Path) – Path to the DVA Excel file

Returns:

  • date: datetime (first day of month)

  • year: int

  • month: str (month name)

  • tests_conducted: int (theory tests conducted)

  • rolling_12_month_total: int (optional, rolling 12-month sum)

Return type:

DataFrame with columns

Example

>>> url, _, _ = get_latest_dva_publication_url()
>>> path = _download_file(url)
>>> df = parse_theory_tests(path)
>>> 'tests_conducted' in df.columns
True
>>> len(df) > 0
True
bolster.data_sources.dva.get_latest_vehicle_tests(force_refresh=False)[source]

Get the latest vehicle test statistics.

Downloads and parses the most recent DVA monthly tests publication. Results are cached for 7 days unless force_refresh=True.

Parameters:

force_refresh (bool) – If True, bypass cache and download fresh data

Returns:

DataFrame with monthly vehicle test data

Return type:

pandas.DataFrame

Example

>>> df = get_latest_vehicle_tests()
>>> 'tests_conducted' in df.columns
True
bolster.data_sources.dva.get_latest_driver_tests(force_refresh=False)[source]

Get the latest driver test statistics.

Downloads and parses the most recent DVA monthly tests publication. Results are cached for 7 days unless force_refresh=True.

Parameters:

force_refresh (bool) – If True, bypass cache and download fresh data

Returns:

DataFrame with monthly driver test data

Return type:

pandas.DataFrame

Example

>>> df = get_latest_driver_tests()
>>> len(df) > 0
True
bolster.data_sources.dva.get_latest_theory_tests(force_refresh=False)[source]

Get the latest theory test statistics.

Downloads and parses the most recent DVA monthly tests publication. Results are cached for 7 days unless force_refresh=True.

Parameters:

force_refresh (bool) – If True, bypass cache and download fresh data

Returns:

DataFrame with monthly theory test data

Return type:

pandas.DataFrame

Example

>>> df = get_latest_theory_tests()
>>> len(df) > 0
True
bolster.data_sources.dva.get_latest_all_tests(force_refresh=False)[source]

Get all test types (vehicle, driver, theory) from the latest publication.

Downloads the file once and parses all three test types.

Parameters:

force_refresh (bool) – If True, bypass cache and download fresh data

Returns:

Dictionary with keys ‘vehicle’, ‘driver’, ‘theory’ containing DataFrames

Return type:

dict[str, pandas.DataFrame]

Example

>>> data = get_latest_all_tests()
>>> sorted(data.keys())
['driver', 'theory', 'vehicle']
bolster.data_sources.dva.get_tests_by_year(df, year)[source]

Filter test data for a specific year.

Parameters:
Returns:

DataFrame with only the specified year’s data

Return type:

pandas.DataFrame

Example

>>> df = get_latest_vehicle_tests()
>>> df_2024 = get_tests_by_year(df, 2024)
>>> 'tests_conducted' in df_2024.columns
True
bolster.data_sources.dva.get_tests_by_month(df, month, year)[source]

Get test data for a specific month and year.

Parameters:
  • df (pandas.DataFrame) – Test statistics DataFrame

  • month (str) – Month name (e.g., ‘January’, ‘December’)

  • year (int) – Year

Returns:

DataFrame with single row for the specified month

Return type:

pandas.DataFrame

Example

>>> df = get_latest_vehicle_tests()
>>> dec_2025 = get_tests_by_month(df, 'December', 2025)
>>> 'tests_conducted' in dec_2025.columns
True
bolster.data_sources.dva.calculate_growth_rates(df, periods=12)[source]

Calculate year-on-year growth rates for test statistics.

Parameters:
  • df (pandas.DataFrame) – Test statistics DataFrame

  • periods (int) – Number of months for comparison (default: 12 for YoY)

Returns:

  • yoy_growth: Percentage change vs same month previous year

Return type:

DataFrame with additional column

Example

>>> df = get_latest_vehicle_tests()
>>> df_growth = calculate_growth_rates(df)
>>> 'yoy_growth' in df_growth.columns
True
bolster.data_sources.dva.get_summary_statistics(df, start_year=None, end_year=None)[source]

Calculate summary statistics for test data.

Parameters:
  • df (pandas.DataFrame) – Test statistics DataFrame

  • start_year (int | None) – Optional start year for summary

  • end_year (int | None) – Optional end year for summary

Returns:

  • period: Time period covered

  • total_tests: Total tests in period

  • monthly_mean: Average monthly tests

  • monthly_min: Minimum monthly tests

  • monthly_max: Maximum monthly tests

  • months_count: Number of months included

Return type:

Dictionary with summary statistics

Example

>>> df = get_latest_vehicle_tests()
>>> stats = get_summary_statistics(df, start_year=2020)
>>> sorted(stats.keys())
['monthly_max', 'monthly_mean', 'monthly_min', 'months_count', 'period', 'total_tests']
bolster.data_sources.dva.validate_dva_test_data(df)[source]

Validate DVA test statistics data integrity.

Parameters:

df (pandas.DataFrame) – DataFrame from DVA test functions (vehicle, driver, or theory tests)

Returns:

True if validation passes, False otherwise

Return type:

bool