datatable.unique()¶
Find the unique values in all the columns of the frame.
This function sorts the values in order to find the uniques, so the return values will be ordered. However, this should be considered an implementation detail: in the future datatable may switch to a different algorithm, such as hash-based, which may return the results in a different order.
Parameters¶
FrameInput frame.
NotImplementedErrorThe exception is raised when one of the frame columns has stype obj64.
Examples¶
from datatable import dt
df = dt.Frame({'A': [1, 1, 2, 1, 2],
'B': [None, 2, 3, 4, 5],
'C': [1, 2, 1, 1, 2]})
df
| A | B | C | ||
|---|---|---|---|---|
| int32 | int32 | int32 | ||
| 0 | 1 | NA | 1 | |
| 1 | 1 | 2 | 2 | |
| 2 | 2 | 3 | 1 | |
| 3 | 1 | 4 | 1 | |
| 4 | 2 | 5 | 2 |
Unique values in the entire frame:
dt.unique(df)
| C0 | ||
|---|---|---|
| int32 | ||
| 0 | NA | |
| 1 | 1 | |
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | |
| 5 | 5 |
Unique values in a frame with a single column:
dt.unique(df["A"])
| A | ||
|---|---|---|
| int32 | ||
| 0 | 1 | |
| 1 | 2 |
See Also¶
intersect()– calculate the set intersection of values in the frames.setdiff()– calculate the set difference between the frames.symdiff()– calculate the symmetric difference between the sets of values in the frames.union()– calculate the union of values in the frames.