2019-12-31 04:05:02 +00:00
|
|
|
# uniq
|
|
|
|
|
|
|
|
Returns unique rows or values from a dataset.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Given a file `test.csv`
|
|
|
|
|
|
|
|
```
|
|
|
|
first_name,last_name,rusty_at,type
|
|
|
|
Andrés,Robalino,10/11/2013,A
|
|
|
|
Andrés,Robalino,10/11/2013,A
|
|
|
|
Jonathan,Turner,10/12/2013,B
|
|
|
|
Yehuda,Katz,10/11/2013,A
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
> `open test.csv | uniq`
|
|
|
|
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━
|
|
|
|
# │ first_name │ last_name │ rusty_at │ type
|
|
|
|
───┼────────────┼───────────┼────────────┼──────
|
2020-02-18 14:37:46 +00:00
|
|
|
0 │ Andrés │ Robalino │ 10/11/2013 │ A
|
|
|
|
1 │ Jonathan │ Turner │ 10/12/2013 │ B
|
|
|
|
2 │ Yehuda │ Katz │ 10/11/2013 │ A
|
2019-12-31 04:05:02 +00:00
|
|
|
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
> `open test.csv | get type | uniq`
|
|
|
|
━━━┯━━━━━━━━━
|
2020-02-18 14:37:46 +00:00
|
|
|
# │ <value>
|
2019-12-31 04:05:02 +00:00
|
|
|
───┼─────────
|
2020-02-18 14:37:46 +00:00
|
|
|
0 │ A
|
|
|
|
1 │ B
|
2019-12-31 04:05:02 +00:00
|
|
|
━━━┷━━━━━━━━━
|
|
|
|
```
|
2020-06-21 00:22:06 +00:00
|
|
|
|
|
|
|
### Counting
|
|
|
|
`--count` or `-c` is the flag to output a `count` column.
|
|
|
|
|
|
|
|
```
|
|
|
|
> `open test.csv | get type | uniq -c`
|
|
|
|
───┬───────┬───────
|
|
|
|
# │ value │ count
|
|
|
|
───┼───────┼───────
|
|
|
|
0 │ A │ 3
|
|
|
|
1 │ B │ 2
|
|
|
|
───┴───────┴───────
|
|
|
|
```
|