difference between 2 arrays

Matthias Huening mhuening at zedat.fu-berlin.de
Wed Aug 19 10:44:48 EDT 2009


Pierre (19.08.2009 10:48):
> Hello,
> 
> 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]
> 

What about set()?

 >>> a = set([1,2, 3,2,5,2])
 >>> b = set([1,2])
 >>> a.difference(b)
set([3, 5])


Matthias



More information about the Python-list mailing list