[Numpy-discussion] FW: numpy array matching

Chris Barker cbarker at jps.net
Wed Mar 14 12:13:13 CST 2001


Chris Barker wrote:
> >>> t = array(['abcd','aacd','ddfa','qqcd'])
> 
> >>> t2 = t.astype(UnsignedInt8)
> 
> >>> nonzero(equal(t2,ord('c'))[:,2])
> 
> array([0, 1, 3])

OOPS. For a little better performance:

>>> nonzero(equal(t2[:,2],ord('c')))

array([0, 1, 3])


-- 
Christopher Barker,
Ph.D.                                                           
cbarker at jps.net                      ---           ---           ---
http://www.jps.net/cbarker          -----@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Water Resources Engineering       ------   @    ------   @   ------   @
Coastal and Fluvial Hydrodynamics -------      ---------     --------    
------------------------------------------------------------------------
------------------------------------------------------------------------




More information about the Numpy-discussion mailing list