Python Practice › NumPy Programs › Program 56
Set difference
Write a NumPy program to find the unique values of array1 that are not in array2.
Input
[56, 18, 28, 36], [76, 36, 56]
Output
[18 28]
Approach
np.setdiff1d.
Solution
import numpy as npprint(np.setdiff1d([56, 18, 28, 36], [76, 36, 56]))Output
[18 28]
Learn the concept
New to this topic? Read the lesson, then come back.