uniq-by for filters
Return the distinct values in the input by the given column(s).
Signature
> uniq-by {flags} ...rest
Flags
-
--count, -c: Return a table containing the distinct input values together with their counts. -
--keep-last, -l: Return the last occurrence of each unique value instead of the first. -
--repeated, -d: Return the input values that occur more than once. -
--ignore-case, -i: Ignore differences in case when comparing input values. -
--unique, -u: Return the input values that occur once only.
Parameters
-
...rest: The column(s) to filter by.
Input/output types:
| input | output |
|---|---|
| table | table |
| list<any> | list<any> |
Examples
Get rows from table filtered by column uniqueness.
> [[fruit count]; [apple 9] [apple 2] [pear 3] [orange 7]] | uniq-by fruit ╭───┬────────┬───────╮ │ # │ fruit │ count │ ├───┼────────┼───────┤ │ 0 │ apple │ 9 │ │ 1 │ pear │ 3 │ │ 2 │ orange │ 7 │ ╰───┴────────┴───────╯
Get rows from table filtered by column uniqueness, keeping the last occurrence of each duplicate.
> [[fruit count]; [apple 9] [apple 2] [pear 3] [orange 7]] | uniq-by fruit --keep-last ╭───┬────────┬───────╮ │ # │ fruit │ count │ ├───┼────────┼───────┤ │ 0 │ apple │ 2 │ │ 1 │ pear │ 3 │ │ 2 │ orange │ 7 │ ╰───┴────────┴───────╯
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/uniq-by.html