[Numpy-discussion] finding elements that match any in a set
Michael Katz
michaeladamkatz at yahoo.com
Fri May 27 12:48:15 EDT 2011
I have a numpy array, records, with named fields including a field named
"integer_field". I have an array (or list) of values of interest, and I want to
get the indexes where integer_field has any of those values.
Because I can do
indexes = np.where( records.integer_field > 5 )
I thought I could do
indexes = np.where( records.integer_field in values )
But that doesn't work. (As a side question I'm interested in why that doesn't
work, when values is a python list.)
How can I get those indexes? I though perhaps I need a nested np.where, or some
other two-step process, but it wasn't clear to me how to do it.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110527/6ae31a7b/attachment.html>
More information about the NumPy-Discussion
mailing list