W3cubDocs

/Nushell

dfr flatten for lazyframe

An alias for dfr explode

Signature

> dfr flatten {flags} ...rest

Parameters

  • ...rest: columns to flatten, only applicable for dataframes

Input/output types:

input output
any any

Examples

Flatten the specified dataframe

> [[idnamehobbies]; [1Mercy [CyclingKnitting]] [2Bob [SkiingFootball]]] |dfr into-df|dfr flattenhobbies|dfr collect
╭───┬────┬───────┬──────────╮
# │ id │ name  │ hobbies  │
├───┼────┼───────┼──────────┤
01MercyCycling
11MercyKnitting
22BobSkiing
32BobFootball
╰───┴────┴───────┴──────────╯

Select a column and flatten the values

> [[idnamehobbies]; [1Mercy [CyclingKnitting]] [2Bob [SkiingFootball]]] |dfr into-df|dfr select (dfr colhobbies|dfr flatten)
╭───┬──────────╮
# │ hobbies  │
├───┼──────────┤
0Cycling
1Knitting
2Skiing
3Football
╰───┴──────────╯

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_flatten.html