Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active January 20, 2021 07:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save IndhumathyChelliah/e63642f1bd6ae4de089c89a461cc108b to your computer and use it in GitHub Desktop.
import numpy as np
a1=np.array(["red","green","yellow"])
a2=np.array(["red","green","blue"])
#intersection
print(np.intersect1d(a1,a2))
#Output:['green' 'red']
#union
print(np.union1d(a1,a2))
#Output:['blue' 'green' 'red' 'yellow']
#difference
print(np.setdiff1d(a1,a2))
#Output:['yellow']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment