dfr with-column for dataframe or lazyframe

Adds a series to the dataframe.

Signature

> dfr with-column ...rest --name

Parameters

  • ...rest: series to be added or expressions used to define the new columns
  • --name {string}: new column name

Input/output types:

inputoutput
anyany

Examples

Adds a series to the dataframe

> [[a b]; [1 2] [3 4]]
    | dfr into-df
    | dfr with-column ([5 6] | dfr into-df) --name c
╭───┬───┬───┬───╮
│ # │ a │ b │ c │
├───┼───┼───┼───┤
│ 0125 │
│ 1346 │
╰───┴───┴───┴───╯

Adds a series to the dataframe

> [[a b]; [1 2] [3 4]]
    | dfr into-lazy
    | dfr with-column [
        ((dfr col a) * 2 | dfr as "c")
        ((dfr col a) * 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