dfr otherwise для выражения
завершает выражение when.
Подпись
> dfr otherwise {flags} (otherwise expression)
Параметры
-
otherwise expression: выражение, применяемое, если ни один предикат when не соответствует
Типы входных/выходных данных:
| вход | выход |
|---|---|
| любой | любой |
Примеры
Создайте условия when
>dfr when ((dfr cola) >2) 4|dfr otherwise5
Создайте условия when
>dfr when ((dfr cola) >2) 4|dfr when ((dfr cola) <0) 6|dfr otherwise0
Создайте новый столбец для фрейма данных
> [[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│
╰───┴───┴───┴───┴────╯
Советы: Команды фрейма данных по умолчанию не включены в официальные двоичные файлы. Их необходимо скомпилировать с флагом --features=dataframe
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/dfr_otherwise.html