W3cubDocs

/Nushell

dfr with-column for dataframe or lazyframe

Adds a series to the dataframe.

Signature

> dfr with-column {flags} ...rest

Flags

  • --name, -n {string}: new column name

Parameters

  • ...rest: series to be added or expressions used to define the new columns

Input/output types:

input output
any any

Examples

Adds a series to the dataframe

> [[ab]; [12] [34]]
|dfr into-df
|dfr with-column ([56] |dfr into-df) --namec
╭───┬───┬───┬───╮
# │ a │ b │ c │
├───┼───┼───┼───┤
0125
1346
╰───┴───┴───┴───╯

Adds a series to the dataframe

> [[ab]; [12] [34]]
|dfr into-lazy
|dfr with-column [
        ((dfr cola) *2|dfr as"c")
        ((dfr cola) *3|dfr as"d")
      ]
|dfr collect
╭───┬───┬───┬───┬───╮
# │ a │ b │ c │ d │
├───┼───┼───┼───┼───┤
01223
13469
╰───┴───┴───┴───┴───╯

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_with-column.html