Find the set difference between two arrays using NumPy

In this python numpy program, we will find the set difference between two arrays using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create two arrays using np.array().
  3. Find the set difference between two arrays using np.setdiff1d().
  4. Print the output
				
					import numpy as np
x = np.array([56,18,28,36])
y = np.array([76,36,56])

print(np.setdiff1d(x,y))
				
			

Output :

				
					[18 28]
				
			

get the unique elements of an array.

find the union of two arrays.

Leave a Comment