NumPy | setdiff1d method
Start your free 7-days trial now!
setdiff1d(~) method returns the unique values in
a that does not exist in
The first array.
The second array.
b contain only uniques, set this to
True as it will boost performance. By default,
A Numpy array that contains the unique values of the first array that does not exist in the second array.
a = np.array([5,4,2,2])b = np.array([5,2,5,3])np.setdiffd(a,b)array()
 is returned because of two steps:
we first only consider the unique values in
a, that is,
next, the values 5 and 2 exist in
b, so they are removed as well.