Unpivot a DataFrame from wide format to long format — mirrors
pandas.melt() / DataFrame.melt().
Edit any code block below and press ▶ Run
(or Ctrl+Enter) to execute it live in your browser.
Melt all value columns into a single variable / value
pair.
Use id_vars to keep columns as identifiers that are repeated for
each melted row.
Use value_vars to specify which columns to unpivot.
Pass an array to id_vars to use multiple identifier columns.
Unpivot a DataFrame from wide to long format. Columns not specified as
id_vars or value_vars are melted into
variable / value pairs.
melt(df: DataFrame, options?: {
id_vars?: string | string[], // columns to keep as identifiers
value_vars?: string | string[], // columns to unpivot (default: all non-id)
var_name?: string, // name for the variable column (default: "variable")
value_name?: string, // name for the value column (default: "value")
}): DataFrame