tidysdmx
  • User Guide
  • Reference

Skills

A skill is a package of structured files that teaches an AI coding agent how to work with a specific tool or framework. The skill below was generated by Great Docs from this project’s documentation. Install it in your agent and it will be able to run commands, edit configuration, write content, and troubleshoot problems without step-by-step guidance from you.

Any agent — install with npx:

npx skills add 

Works with Claude Code, GitHub Copilot, Cursor, Gemini CLI, Codex, and 30+ other agents.

Codex / OpenCode — tell the agent:

Fetch the skill file at <site-url>/skill.md and follow the instructions.

Manual — download the skill file:

curl -O <site-url>/skill.md

Or browse the SKILL.md file.

SKILL.md

---
name: tidysdmx
description: >
  Use when writing Python code that uses the tidysdmx package.
---

# tidysdmx

## Installation

```bash
pip install tidysdmx
```

## API overview

### FMR & Schemas

Fetch and parse SDMX schemas from a Fusion Metadata Registry.

- `fetch_schema`: Fetch the schema of a specified artefact from an SDMX registry
- `fetch_dsd_schema`: Fetch a DSD schema from a Fusion Metadata Registry (FMR)
- `parse_artefact_id`: Parse an artefact identifier into its components: agency, id and version
- `parse_dsd_id`: Parse a DSD identifier into its components
- `create_schema_from_table`: Create a DSD, ConceptScheme, and Codelists from a DataFrame

### Structure Maps

Build, parse, validate, and write SDMX structure maps.

- `parse_mapping_template_wb`: Read an Excel mapping template and return all sheets as DataFrames
- `build_structure_map_from_template_wb`: Build a complete StructureMap object by parsing a WB-format Excel template
- `build_fixed_map`: Build a pysdmx FixedValueMap for setting a component to a fixed value
- `build_implicit_component_map`: Build a pysdmx ImplicitComponentMap for implicit mapping rules
- `build_date_pattern_map`: Build a DatePatternMap object for mapping date patterns between SDMX components
- `build_value_map`: Create a pysdmx ValueMap object mapping a source value to a target value
- `build_value_map_list`: Build a list of ValueMap objects from a pandas DataFrame, optionally including validity periods
- `build_multi_value_map_list`: Build a list of MultiValueMap objects from a pandas DataFrame
- `build_representation_map`: Build a RepresentationMap object from a pandas DataFrame using build_value_map_list
- `build_multi_representation_map`: Build a MultiRepresentationMap object from a pandas DataFrame
- `build_single_component_map`: Build a ComponentMap mapping one source component to one target component using a RepresentationMap built from a pandas DataFrame
- `collect_structure_map_artifacts`: Collect the StructureMap and all its dependent RepresentationMaps
- `validate_structure_map_references`: Validate that all RepresentationMap references are resolved
- `prepare_structure_map_for_upload`: Prepare a StructureMap for upload by collecting all dependencies

### Mapping

Apply structure maps to tidy DataFrames.

- `map_structures`: Apply all mapping components from a StructureMap to a DataFrame
- `apply_fixed_value_maps`: Apply FixedValueMap rules to a DataFrame
- `apply_implicit_component_maps`: Apply ImplicitComponentMap rules to a DataFrame
- `apply_multi_component_map`: Apply a single MultiComponentMap with regex support, preserving rule order
- `map_to_sdmx`: Map DataFrame columns to SDMX values using a lookup mapping
- `transform_source_to_target`: Transform a raw DataFrame into the format defined by a components map

### Standardisation

Prepare a mapped DataFrame for SDMX upload.

- `standardize_output`: Standardize the output DataFrame by adding SDMX reference columns
- `standardize_sdmx`: Standardize a DataFrame by applying column and value transformations
- `standardize_data_for_upload`: Standardize a DataFrame for SDMX upload
- `standardize_indicator_id`: Fix the INDICATOR column to be uppercase and prefixed with dataset ID
- `sanitize_variable`: Sanitize a raw string value into a valid SDMX code ID
- `add_sdmx_reference_cols`: Add SDMX reference columns to a DataFrame

### Validation

Validate datasets against schemas and codelists.

- `validate_dataset_local`: Validate that a DataFrame is SDMX compliant and return a DataFrame of errors
- `validate_columns`: Validate that all DataFrame columns are valid components or SDMX references
- `validate_mandatory_columns`: Validate that all mandatory columns are present in the DataFrame
- `validate_codelist_ids`: Validate that all values in coded columns are within the allowed codelist IDs
- `validate_duplicates`: Validate that there are no duplicate rows for a given set of key columns
- `validate_no_missing_values`: Validate that there are no missing values in mandatory columns

### Tidy Raw

Filter and shape raw inputs.

- `filter_tidy_raw`: Filter an SDMX DataFrame by removing rows that violate codelist constraints
- `filter_rows`: Filter out rows where values are not in the allowed codelist

### Utilities

Helpers for codelists, components, Excel templates, and XML.

- `extract_validation_info`: Extract validation information from a given schema
- `get_codelist_ids`: Retrieve all codelist IDs for given coded components
- `extract_component_ids`: Retrieve all component IDs from a given pysdmx Schema
- `create_mapping_rules`: Create Excel hyperlink formulas for components with representation maps
- `build_excel_workbook`: Build a Workbook with component mapping and representation map sheets
- `write_excel_mapping_template`: Generate an Excel mapping template with component and representation tabs
- `read_mapping`: Read a JSON mapping file and parse its content into DataFrames
- `fix_sdmx_xml_datatype_tags`: Fix incorrect SourceCodelist/TargetCodelist tags in SDMX-ML
- `gen_urn`: Generate a full SDMX URN for any maintainable artefact

### QA

Quality-assurance helpers.

- `qa_coerce_numeric`: Coerce specified columns to numeric, removing rows with invalid values
- `qa_remove_duplicates`: Remove duplicate rows from a DataFrame

### Kedro Integration

Kedro pipeline node wrappers.

- `kd_read_mappings`: Fetch multiple mappings from different files
- `kd_standardize_sdmx`: Standardize a partitioned dataset into SDMX format
- `kd_validate_dataset_local`: Validate a single DataFrame for SDMX compliance
- `kd_validate_datasets_local`: Validate multiple datasets for SDMX compliance

### Lookups

Vectorised lookup helpers.

- `vectorized_lookup_ordered_v1`: Apply ordered regex matching to a Pandas Series
- `vectorized_lookup_ordered_v2`: Apply ordered matching (regex or exact) to a Pandas Series

## Resources

- [llms.txt](llms.txt) — Indexed API reference for LLMs
- [llms-full.txt](llms-full.txt) — Comprehensive documentation for LLMs

Developed by Tony Fujs and Daniel Gil-Sanchez. Supported by The World Bank.
Site created with Great Docs.