| [ Web Proxy ] |
| Viewing: https://numpy.org/doc/stable/reference/generated/../generated/../generated/numpy.unique_all.html | [Back] [Original] |
Find the unique elements of an array, and counts, inverse, and indices.
This function is an Array API compatible alternative to:
np.unique(x, return_index=True, return_inverse=True,
return_counts=True, equal_nan=False, sorted=False)
but returns a namedtuple for easier access to each output.
Note
This function currently always returns a sorted result, however, this could change in any NumPy minor release.
Input array. It will be flattened if it is not already 1-D.
The result containing:
values - The unique elements of an input array.
indices - The first occurring indices for each unique element.
inverse_indices - The indices from the set of unique elements that reconstruct x.
counts - The corresponding counts for each unique element.
See also
uniqueFind the unique elements of an array.
Examples
>>> import numpy as np
>>> x = [1, 1, 2]
>>> uniq = np.unique_all(x)
>>> uniq.values
array([1, 2])
>>> uniq.indices
array([0, 2])
>>> uniq.inverse_indices
array([0, 0, 1])
>>> uniq.counts
array([2, 1])
| Web Proxy Viewer | New URL | Original Page |