What is the best way to delete the elements from one numpy array in another? Essentially I'm after np.delete() where the order of the arrays doesn't matter.
import numpy as np
a = np.array([2,1,3])
print a
b = np.array([4,1,2,5,2,3])
b = np.delete(b, a) # doesn't work as desired
print b # want [4,5,2]
Iterating over the elements of a is very slow for large arrays.
[4,5,2]?2is also ina, so it should be removed andbwould be[4,5].a. As writtenahas two2's.a = [2,2,1,3],b == [4,5]? What ifa = [2,2,2,1,3]? Your case is too unspecific as it currently stands.b == [4,5]. In the second case I already know thataonly contains elements withinb.ahave duplicate values too like :a = [2,2,1,3]?