dfr group-by for lazyframe

Creates a group-by object that can be used for other aggregations.

WARNING

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

Signature

> dfr group-by {flags} ...rest

Parameters

  • ...rest: Expression(s) that define the lazy group-by

Input/output types:

inputoutput
anyany

Examples

Group by and perform an aggregation

> [[a b]; [1 2] [1 4] [2 6] [2 4]]
    | dfr into-df
    | dfr group-by a
    | dfr agg [
        (dfr col b | dfr min | dfr as "b_min")
        (dfr col b | dfr max | dfr as "b_max")
        (dfr col b | dfr sum | dfr as "b_sum")
     ]
╭───┬───┬───────┬───────┬───────╮
 # │ a │ b_min │ b_max │ b_sum │
├───┼───┼───────┼───────┼───────┤
 0  1      2      4      6 
 1  2      4      6     10 
╰───┴───┴───────┴───────┴───────╯

Group by and perform an aggregation

> [[a b]; [1 2] [1 4] [2 6] [2 4]]
    | dfr into-lazy
    | dfr group-by a
    | dfr agg [
        (dfr col b | dfr min | dfr as "b_min")
        (dfr col b | dfr max | dfr as "b_max")
        (dfr col b | dfr sum | dfr as "b_sum")
     ]
    | dfr collect
╭───┬───┬───────┬───────┬───────╮
 # │ a │ b_min │ b_max │ b_sum │
├───┼───┼───────┼───────┼───────┤
 0  1      2      4      6 
 1  2      4      6     10 
╰───┴───┴───────┴───────┴───────╯