Reshape wide-format data to long format using named column groups —
mirrors pandas.lreshape().
Edit any code block below and press ▶ Run
(or Ctrl+Enter) to execute it live in your browser.
Stack two wide columns (v1, v2) into a single long
column v, repeating the id column for each block.
Reshape with multiple output columns simultaneously. Each output column is fed from a separate list of input columns.
By default rows where any value column is null/NaN
are dropped. Pass dropna: false to keep them.
Stack multiple rounds of survey scores into a long-format table.
Reshape wide-format data to long format by explicitly naming which input columns map to each output column.
lreshape(
data: DataFrame,
groups: Record<string, string[]>, // { outputCol: [inputCol1, inputCol2, ...] }
options?: {
dropna?: boolean, // drop rows with null/NaN values (default: true)
}
): DataFrame
All input columns not mentioned in groups
become identity (id) columns and are repeated for each block. All group lists must
have the same length k; the result has nRows × k rows
(before applying dropna).