A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://numpy.org/doc/stable/reference/generated/numpy.unique_inverse.html below:

numpy.unique_inverse — NumPy v2.3 Manual

numpy.unique_inverse#
numpy.unique_inverse(x)[source]#

Find the unique elements of x and indices to reconstruct x.

This function is an Array API compatible alternative to:

np.unique(x, return_inverse=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.

Parameters:
xarray_like

Input array. It will be flattened if it is not already 1-D.

Returns:
outnamedtuple

The result containing:

  • values - The unique elements of an input array.

  • inverse_indices - The indices from the set of unique elements that reconstruct x.

See also

unique

Find the unique elements of an array.

Examples

>>> import numpy as np
>>> x = [1, 1, 2]
>>> uniq = np.unique_inverse(x)
>>> uniq.values
array([1, 2])
>>> uniq.inverse_indices
array([0, 0, 1])

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4