group-by for default

Splits a list or table into groups, and returns a record containing those groups.

Signature

> group-by (grouper)

Parameters

  • grouper: the grouper value to use

Examples

Group items by the "type" column's values

> ls | group-by type

You can also group by raw values by leaving out the argument

> ['1' '3' '1' '3' '2' '1' '1'] | group-by
╭───┬───────────╮
│   │ ╭───┬───╮ │
│ 1 │ │ 01 │ │
│   │ │ 11 │ │
│   │ │ 21 │ │
│   │ │ 31 │ │
│   │ ╰───┴───╯ │
│   │ ╭───┬───╮ │
│ 3 │ │ 03 │ │
│   │ │ 13 │ │
│   │ ╰───┴───╯ │
│   │ ╭───┬───╮ │
│ 2 │ │ 02 │ │
│   │ ╰───┴───╯ │
╰───┴───────────╯