dfr dummies for dataframe

Creates a new dataframe with dummy variables.

Signature

> dfr dummies {flags}

Flags

  • --drop-first, -d: Drop first row

Input/output types:

input output
any any

Examples

Create new dataframe with dummy variables from a dataframe

> [[a b]; [1 2] [3 4]] | dfr into-df | dfr dummies
╭───┬─────┬─────┬─────┬─────╮
│ # │ a_1 │ a_3 │ b_2 │ b_4 │
├───┼─────┼─────┼─────┼─────┤
│ 0 │   1 │   0 │   1 │   0 │
│ 1 │   0 │   1 │   0 │   1 │
╰───┴─────┴─────┴─────┴─────╯

Create new dataframe with dummy variables from a series

> [1 2 2 3 3] | dfr into-df | dfr dummies
╭───┬─────┬─────┬─────╮
│ # │ 0_1 │ 0_2 │ 0_3 │
├───┼─────┼─────┼─────┤
│ 0 │   1 │   0 │   0 │
│ 1 │   0 │   1 │   0 │
│ 2 │   0 │   1 │   0 │
│ 3 │   0 │   0 │   1 │
│ 4 │   0 │   0 │   1 │
╰───┴─────┴─────┴─────╯

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