difference between 2 arrays

Matthias Huening mhuening at zedat.fu-berlin.de
Wed Aug 19 16:44:48 CEST 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