On Fri, May 27, 2011 at 12:48 PM, Michael Katz <michaeladamk...@yahoo.com> wrote: > 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. >
Check out this recent thread. I think the proposed class does what you want. It's more efficient than in1d, if values is small compared to the length of records. http://thread.gmane.org/gmane.comp.python.scientific.user/29035/ Skipper _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion