count
Count the rows in each group, one output row per group.
NoteExperimental
This function is experimental; its interface may change without notice.
Since 0.6.0.
The positional string columns are the grouping; with no columns the result is a single row holding the total. The tally lands in a plain n column. sort: true orders the rows by descending n, ties keeping their first-appearance order.
Usage
count(
data,
..cols,
sort: false,
)Parameters
| Parameter | Default | Description |
|---|---|---|
data |
Row-store (array of dicts) or column-store (dict of arrays). | |
..cols |
Grouping columns as positional strings; none for a grand total. | |
sort |
false |
When true, order rows by descending n. |
Returns
A row-store array with the grouping columns and an n column.
Examples
Rows per class, most frequent first.
#let per-class = count(mpg, "class", sort: true)