[Numpy-discussion] finding elements that match any in a set
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion