[Numpy-discussion] FW: numpy array matching

Paul F. Dubois paul at pfdubois.com
Wed Mar 14 09:53:42 EST 2001

The obvious approach using equal doesn't seem to work. I'll forward your
-- Paul
-----Original Message-----
From: Sam Tannous [mailto:stannous at cisco.com]
Sent: Wednesday, March 14, 2001 3:31 AM
To: Paul F. Dubois
Subject: numpy array matching


I can't seem to get my question posted to
the discussion list.  Could you please
post it for me? (Or even answer it for me?)


If I have a character array t:

>>> t = array(['abcd','aacd','ddfa','qqcd'])
>>> print t
[[a b c d]
 [a a c d]
 [d d f a]
 [q q c d]]

I'm trying to find the row numbers that
have a 'c' in the third column
(and I'm trying to avoid a 'for' loop).

What's the most efficient way to
create an array that contains the indexes
of the rows that match a particular pattern?
(using masks?)

The answer should be an array ([0,1,3])

Thanks for any tips,

More information about the NumPy-Discussion mailing list