dpnp.unique_counts

dpnp.unique_counts(x, /)

Find the unique elements and counts of an input array x.

For full documentation refer to numpy.unique_counts.

Parameters:

x ({dpnp.ndarray, usm_ndarray}) -- Input array. It will be flattened if it is not already 1-D.

Returns:

A namedtuple with the following attributes
  • values (dpnp.ndarray) -- The unique elements of an input array.

  • counts (dpnp.ndarray) -- The corresponding counts for each unique element.

See also

dpnp.unique

Find the unique elements of an array.

Examples

>>> import dpnp as np
>>> x = np.array([1, 1, 2])
>>> uniq = np.unique_counts(x)
>>> uniq.values
array([1, 2])
>>> uniq.counts
array([2, 1])