dfr otherwise
for expression> dfr otherwise {flags} (otherwise expression)
otherwise expression
: expression to apply when no when predicate matchesinput | output |
---|---|
any | any |
Create a when conditions
>dfr when ((dfr cola) >2) 4|dfr otherwise5
Create a when conditions
>dfr when ((dfr cola) >2) 4|dfr when ((dfr cola) <0) 6|dfr otherwise0
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_otherwise.html