distinct

Keep the first row of each distinct combination of the named columns.

NoteExperimental

This function is experimental; its interface may change without notice.

Since 0.6.0.

Positional columns form the key; the first row seen for each key is kept, in first-appearance order, with every column retained. With no columns the whole row is the key (native .dedup()).

Usage

distinct(
  data,
  ..cols,
)

Parameters

Parameter Default Description
data Row-store (array of dicts) or column-store (dict of arrays).
..cols Key columns, as positional strings; none keys on the whole row.

Returns

A row-store array with duplicate keys removed.

Examples

One representative row per class.

#let one-each = distinct(mpg, "class")

See also

drop-na.

Back to top