Q:

Write a NumPy program to find the set difference of two arrays. The set difference will return the sorted,

0

Write a NumPy program to find the set difference of two arrays. The set difference will return the sorted, 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
array1 = np.array([0, 10, 20, 40, 60, 80])
print("Array1: ",array1)
array2 = [10, 30, 40, 50, 70]
print("Array2: ",array2)
print("Unique values in array1 that are not in array2:")
print(np.setdiff1d(array1, array2))

Sample Output:

Array1:  [ 0 10 20 40 60 80]                                           
Array2:  [10, 30, 40, 50, 70]                                          
Unique values in array1 that are not in array2:                        
[ 0 20 60 80]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now