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

frame
Frame

Input frame.

return
Frame

A single-column frame consisting of unique values found in frame. The column stype is the smallest common stype for all the frame columns.

except
NotImplementedError

The exception is raised when one of the frame columns has stype obj64.

Examples

from datatable import dt, f, by df = dt.Frame({'A': [1, 1, 2, 1, 2], 'B': [None, 2, 3,4, 5], 'C': [1, 2, 1, 1, 2]}) df
ABC
int32int32int32
01NA1
1122
2231
3141
4252

Unique values in the entire frame:

dt.unique(df)
C0
int32
0NA
11
22
33
44
55

Unique values in a frame with a single column:

dt.unique(df["A"])
A
int32
01
12

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.