dfr when
for expression> dfr when {flags} (when expression) (then expression)
when expression
: when expression used for matchingthen expression
: expression that will be applied when predicate is trueinput | output |
---|---|
any | any |
Create a when conditions
>dfr when ((dfr cola) >2) 4
Create a when conditions
>dfr when ((dfr cola) >2) 4|dfr when ((dfr cola) <0) 6
Create a new column for the dataframe
> [[ab]; [62] [14] [41]]
|dfr into-lazy
|dfr with-column (
dfr when ((dfr cola) >2) 4|dfr otherwise5|dfr asc
)
|dfr with-column (
dfr when ((dfr cola) >5) 10|dfr when ((dfr cola) <2) 6|dfr otherwise0|dfr asd
)
|dfr collect
╭───┬───┬───┬───┬────╮
│# │ a │ b │ c │ d │
├───┼───┼───┼───┼────┤
│0│6│2│4│10│
│1│1│4│5│6│
│2│4│1│4│0│
╰───┴───┴───┴───┴────╯
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_when.html