Skip to main content

Helper functions for converting data to the NHS CML schema format.

Project description

cml-conversion-helpers

Helper functions for converting tidy-format datasets into the NHS CML schema (metric and dimension tables).

What this library does

CML expects data in two tables:

  • Metric table — one row per data point, with fields such as metric_id, metric_value, location_id, reporting_period_start_datetime, etc.
  • Dimensions table — one row per data point, one column per dimension (e.g. age group, ethnicity), linked to the metric table via dimension_cohort_id.

This library takes a tidy-format source dataset (where dimensions are stored as rows, not columns) and provides utilities to transform it into those two tables.

Installation

pip install cml-conversion-helpers

Modules

  • cml_conversion_helpers.spark_functions.processing — Spark DataFrame transformation functions
  • cml_conversion_helpers.spark_functions.dimension_cohorts — Spark dimension table helpers
  • cml_conversion_helpers.pandas_functions.processing — pandas DataFrame transformation functions
  • cml_conversion_helpers.pandas_functions.dimension_cohorts — pandas dimension table helpers

Documentation

  • Getting Started — installation, concepts, and input data requirements
  • Usage Guide — config-driven, scripting, or hybrid approaches with full examples
  • API Reference — full function reference grouped by module

Development

Before you build and publish, make sure you:

  • Update the README.md if new instructions are needed
  • Update the CHANGELOG.md (paste the git diff since the last version into your favourite bot and ask it to make you a changelog entry)
  • Bump the version number (use SemVer) in pyproject.toml

When you are ready:

python -m venv venv

source venv/bin/activate # if on Linux or...
source venv/Scripts/activate # if on Windows

pip install build twine
python -m build
python -m twine upload dist/* # for PyPi or...
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* # for Test PyPi

You'll be prompted for your API token, paste it in and press enter.

Acknowledgements

Some code written by Claude (Anthropic).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cml_conversion_helpers-0.5.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cml_conversion_helpers-0.5.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file cml_conversion_helpers-0.5.0.tar.gz.

File metadata

  • Download URL: cml_conversion_helpers-0.5.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cml_conversion_helpers-0.5.0.tar.gz
Algorithm Hash digest
SHA256 de033cc199b99ab16ba725b28de3c56bca88a9402e1e01a2598ab04dd1c60ad9
MD5 efc3269f461af56126d7b833add1f1fa
BLAKE2b-256 8360eda46a69bbf4e54c14e6654e08fc15f7ab5e8646b298f5e81b278f79a440

See more details on using hashes here.

File details

Details for the file cml_conversion_helpers-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cml_conversion_helpers-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 483d2068bae3217aa4cacd23a32cb43568b022948b7dfddc17de802bf52586ad
MD5 f38e15059db148fe6aa7109936ae5fe1
BLAKE2b-256 aa8bc7362a38a9e7fe13f5e009fdb62976bf6915031cedbc837bd1db0c1c2870

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page