[Tutor] comparing two numpy arrays

Bob Gailer bgailer at alum.rpi.edu
Tue Aug 7 19:05:02 CEST 2007


Eric Brunson wrote:
> Bob Gailer wrote:
>> Andy Cheesman wrote:
>>  
>>> Hi people,
>>>
>>> If I've two numpy arrays, is there a non-looping way of finding common
>>> values. (the example below has identical shapes for the arrays but this
>>> may not be the case in my scenario)
>>>
>>> e.g
>>> a = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> b = array([ 5,  6,  7,  8,  9, 10, 11, 12, 13, 14])
>>>
>>> answer = array([ 5,6,7,8,9])
>>>     
>> Set union?
>>
>>   
> Did you mean Set intersection?
Yes. Sigh.
>
>


-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC




More information about the Tutor mailing list