we currently have 3 different unpivot extenders, which could be reduced to one if we had parameter support. I propose to have something like this:
@extender(name="unpivot")
def unpivot(df: DataFrame, parameters: dict) -> DataFrame:
prefix = parameters.get("untouched_prefix", "val_")
untouched_columns = [f"`{c}`" for c in df.columns if c.startswith("__") or not c.lower().startswith(prefix)]
val_columns = [f"`{c}`" for c in df.columns if c.lower().startswith(prefix)]
return df.unpivot(
untouched_columns,
val_columns,
variableColumnName=parameters.get("variableColumnName", "date_name"),
valueColumnName=parameters.get("valueColumnName", "date_value"),
)
we currently have 3 different unpivot extenders, which could be reduced to one if we had parameter support. I propose to have something like this: