dfr cast
for dataframe
Cast a column to a different dtype.
WARNING
Dataframe commands were not shipped in the official binaries by default, you have to build it with --features=dataframe
flag
Signature
> dfr cast {flags} (dtype) (column)
Parameters
dtype
: The dtype to cast the column tocolumn
: The column to cast. Required when used with a dataframe.
Input/output types:
input | output |
---|---|
any | any |
Examples
Cast a column in a dataframe to a different dtype
> [[a b]; [1 2] [3 4]] | dfr into-df | dfr cast u8 a | dfr schema
╭───┬─────╮
│ a │ u8 │
│ b │ i64 │
╰───┴─────╯
Cast a column in a lazy dataframe to a different dtype
> [[a b]; [1 2] [3 4]] | dfr into-df | dfr into-lazy | dfr cast u8 a | dfr schema
╭───┬─────╮
│ a │ u8 │
│ b │ i64 │
╰───┴─────╯
Cast a column in a expression to a different dtype
> [[a b]; [1 2] [1 4]] | dfr into-df | dfr group-by a | dfr agg [ (dfr col b | dfr cast u8 | dfr min | dfr as "b_min") ] | dfr schema