transform_source_to_target()
Transform a raw DataFrame into the format defined by a components map.
Usage
transform_source_to_target(
df,
mapping,
)Creates a new DataFrame with columns as defined in mapping["components"]["TARGET"] and populates it with data from the source DataFrame based on the column names in ["SOURCE"].
Parameters
df: pd.DataFrame-
The input DataFrame with raw data.
mapping: dict- The master mapping dictionary containing a mapping between the input file columns and the columns defined in the schema.
Returns
pd.DataFrame-
The transformed DataFrame with columns as defined in the components
map’s TARGET.
Raises
KeyError-
If the mapping does not contain a
"components"key or its value is empty.