SDMX (compat.sdmx
)#
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.require_compat("sdmx")
c.add(..., "codelist_to_groups", ...)
|
Convert codes into a mapping from parent items to their children. |
|
|
|
Convert |
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()
.- Parameters:
codes – Either a
sdmx.Codelist
object or any iterable ofsdmx.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]#
-
- Returns:
The quantity may have the attributes:
”dataflow_urn”:
urn
of theDataflow
referenced by thedescribed_by
attribute of ds, if any.”structure_urn”:
urn
of theDataStructureDefinition
referenced by thestructured_by
attribute of ds, if any.
- 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]#
-
The resulting data set is structure-specific.
- Parameters:
observation_dimension (
str
orsdmx.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
orsdmx.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
toDataMessage
.- Parameters:
kwargs – observation_dimension and version parameters are both used and passed on to
quantity_to_dataset()
.