Skip to main content

unique

Find the sorted unique elements of an array. Optionally return indices, inverse mapping, and counts.
Returns: NDArray when no optional flags are true. Object { values, indices?, inverse?, counts? } when one or more flags are true.

unique_all

Return sorted unique values along with their first-occurrence indices, inverse mapping, and counts. This is a structured-return alternative to calling unique with all flags set to true.
Returns: An object with four properties: values (sorted unique elements), indices (first-occurrence indices), inverse_indices (mapping to reconstruct input), and counts (element counts).

unique_counts

Return sorted unique values and their counts.
Returns: An object with values (sorted unique elements) and counts (number of occurrences of each).

unique_inverse

Return sorted unique values and the inverse mapping to reconstruct the original array.
Returns: An object with values (sorted unique elements) and inverse_indices (indices into values that reconstruct the original).

unique_values

Return only the sorted unique values (no indices, inverse, or counts).
Returns: NDArray — Sorted unique values.

in1d

Deprecated in v1.3.0 to match NumPy 2.4. Use isin instead — isin preserves the input shape and supports the same invert option.
Test whether each element of a 1D array is also present in a second array. Returns a flattened boolean array.
Returns: NDArray — Boolean array of the same length as ar1 (flattened).

isin

Test whether each element of an array is present in a set of test elements. Unlike in1d, this preserves the shape of the input.
Returns: NDArray — Boolean array with the same shape as element.

intersect1d

Find the sorted intersection of two arrays. Optionally return the indices of the intersecting elements in the original arrays.

union1d

Find the sorted union of two arrays.
Returns: NDArray — Sorted 1D array of unique values present in either input.

setdiff1d

Find the set difference: elements in ar1 that are not in ar2.
Returns: NDArray — Sorted 1D array of values in ar1 that are not in ar2.

setxor1d

Find the symmetric difference: elements that are in either of two arrays, but not in both.
Returns: NDArray — Sorted 1D array of values in exactly one of the two inputs.

trim_zeros

Trim leading and/or trailing zeros from a 1D array.
Returns: NDArray — The trimmed array.