numpy.unique

numpy.unique(x)

Return the sorted, unique elements of an array or sequence.

Parameters:

x : array_like

Input array.

Returns:

y : ndarray

The sorted, unique elements are returned in a 1-D array.

Examples

>>> np.unique([1, 1, 2, 2, 3, 3])
array([1, 2, 3])
>>> a = np.array([[1, 1], [2, 3]])
>>> np.unique(a)
array([1, 2, 3])

Previous topic

numpy.trim_zeros

Next topic

numpy.fliplr

This Page

Quick search