SDMX (compat.sdmx)#

Package documentation

Note that this package is available in PyPI as sdmx1. To install the correct package, use:

pip install genno[sdmx]

To ensure the operators are available:

c = Computer()
c.add(..., "codelist_to_groups", ...)

codelist_to_groups(codes[, dim])

Convert codes into a mapping from parent items to their children.


Convert DataSet to Quantity.

quantity_to_dataset(qty, structure, *[, ...])

Convert Quantity to DataSet.

quantity_to_message(qty, structure, **kwargs)

Convert Quantity to DataMessage.

This module also registers an implementation of write_report() that handles sdmx.message.DataMessage objects, such as those produced by quantity_to_message().

genno.compat.sdmx.operator.codelist_to_groups(codes: Codelist | Iterable[Code], dim: str | None = None) Mapping[str, Mapping[str, List[str]]][source]#

Convert codes into a mapping from parent items to their children.

The returned value is suitable for use with aggregate().

  • codes – Either a sdmx.Codelist object or any iterable of sdmx.Code.

  • dim (str, optional) – Dimension to aggregate. If codes is a code list and dim is not given, the ID of the code list is used; otherwise dim must be supplied.

genno.compat.sdmx.operator.dataset_to_quantity(ds: BaseDataSet) AttrSeries[source]#

Convert DataSet to Quantity.


The quantity may have the attributes:

Return type:


genno.compat.sdmx.operator.quantity_to_dataset(qty: AttrSeries, structure: BaseDataStructureDefinition, *, observation_dimension: str | None = None, version: Version | str | None = None) BaseDataSet[source]#

Convert Quantity to DataSet.

The resulting data set is structure-specific.

  • observation_dimension (str or sdmx.model.common.DimensionComponent, optional) – If given, the resulting data set is arranged in series, with the observation_dimension varying across observations within each series. If not given, the data set is flat, with all dimensions specified for each observation.

  • version (str or sdmx.format.Version, optional) – SDMX data model version to use; default 2.1.

genno.compat.sdmx.operator.quantity_to_message(qty: AttrSeries, structure: DataStructureDefinition, **kwargs) DataMessage[source]#

Convert Quantity to DataMessage.


kwargsobservation_dimension and version parameters are both used and passed on to quantity_to_dataset().