bundles / numpy 2.4.3 / numpy / setdiff1d
_ArrayFunctionDispatcher
numpy:setdiff1d
Signature
def setdiff1d ( ar1 , ar2 , assume_unique = False ) Summary
Find the set difference of two arrays.
Extended Summary
Return the unique values in ar1 that are not in ar2.
Parameters
ar1: array_likeInput array.
ar2: array_likeInput comparison array.
assume_unique: boolIf True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False.
Returns
setdiff1d: ndarray1D array of values in
ar1that are not inar2. The result is sorted whenassume_unique=False, but otherwise only sorted if the input is sorted.
Examples
import numpy as np a = np.array([1, 2, 3, 2, 4, 1]) b = np.array([3, 4, 5, 6]) np.setdiff1d(a, b)✓
Aliases
-
numpy.setdiff1d