W3cubDocs

/Nushell

dfr explode for lazyframe

Explodes a dataframe or creates a explode expression.

Signature

> dfr explode {flags} ...rest

Parameters

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

Input/output types:

input output
any any

Examples

Explode the specified dataframe

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

Select a column and explode the values

> [[idnamehobbies]; [1Mercy [CyclingKnitting]] [2Bob [SkiingFootball]]] |dfr into-df|dfr select (dfr colhobbies|dfr explode)
╭───┬──────────╮
# │ 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_explode.html