dfr with-column for dataframe or lazyframe

Adds a series to the dataframe.

WARNING

Dataframe commands were not shipped in the official binaries by default, you have to build it with --features=dataframe flag

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:

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 │
├───┼───┼───┼───┤
 0  1  2  5 
 1  3  4  6 
╰───┴───┴───┴───╯

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 │
├───┼───┼───┼───┼───┤
 0  1  2  2  3 
 1  3  4  6  9 
╰───┴───┴───┴───┴───╯