W3cubDocs

/Nushell

dfr melt for dataframe

Unpivot a DataFrame from wide to long format.

Signature

> dfr melt {flags}

Flags

  • --columns, -c {table}: column names for melting
  • --values, -v {table}: column names used as value columns
  • --variable-name, -r {string}: optional name for variable column
  • --value-name, -l {string}: optional name for value column

Input/output types:

input output
any any

Examples

melt dataframe

> [[abcd]; [x14a] [y25b] [z36c]] |dfr into-df|dfr melt-c [bc] -v [ad]
╭───┬───┬───┬──────────┬───────╮
# │ b │ c │ variable │ value │
├───┼───┼───┼──────────┼───────┤
014ax
125ay
236az
314da
425db
536dc
╰───┴───┴───┴──────────┴───────╯

Tips: Dataframe commands were not shipped in the official binaries by default, you have to build it with --features=dataframe flag

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/dfr_melt.html