DataFrame.unpivot

DataFrame unpivot(string[] valueColumns, string[] indexColumns = [], string variableName = "variable", string valueName = "value")

Unpivots the frame long: the valueColumns stack into variableName/valueName pairs (value-column outer, input row inner), the indexColumns repeat per stacked column, and every other column drops - visible in the signature (Polars 2.0 parity; ADR-2026-10-24-20; the full contract lives on ddn.df.reshape.unpivot). Heterogeneous stacks promote only through the numeric lattice and reject otherwise. Eager-only.

Parameters

valueColumnsthe columns to stack (in output order)
indexColumnsthe columns to repeat per stacked column
variableNamethe stacked column-name column
valueNamethe stacked values column

Returns

the unpivoted frame.

Throws

DataFrameException for absent columns or duplicate

output names.