standardize_output()

Standardize the output DataFrame by adding SDMX reference columns.

Usage

Source

standardize_output(
    df,
    artefact_id,
    schema,
    action="I",
)

Enriches the given DataFrame with SDMX-related metadata columns (STRUCTURE, STRUCTURE_ID, ACTION) based on the provided artefact ID and schema, then ensures these columns appear first.

Parameters

df: pd.DataFrame

Input DataFrame containing SDMX data.

artefact_id: str

Unique identifier of the SDMX artefact (e.g., Dataflow ID).

schema: Schema

A pysdmx Schema object used to determine artefact type and filter columns.

action: Literal["I", "U", "D"] = "I"
Action indicator for SDMX operations. Defaults to "I". Allowed values: "I" (Insert), "U" (Update), "D" (Delete).

Returns

pd.DataFrame
A new DataFrame with SDMX reference columns added and reordered.

Raises

ValueError

If df is empty or artefact_id/schema is empty.

TypeError
If df is not a pandas DataFrame.