difference between 2 arrays
Diez B. Roggisch
deets at nospam.web.de
Wed Aug 19 10:54:16 CEST 2009
> I would like to know how to find the difference (set operation)
> between 2 arrays :
> a = array([1,2, 3,2,5,2])
> b = array([1,2])
> I want a - b = [3,5]
> Well, the equivalence of setdiff in matlab...
> I thought a.difference(b) could work, but no : AttributeError:
> 'numpy.ndarray' object has no attribute 'difference'
Not sure if this works with numpy-arrays, but
set(a) - set(b)
might just work if the arrays are iterable.
More information about the Python-list