[Numpy-discussion] how to find array indices at which a condition is satisfied?

Ernest Adrogué eadrogue@gmx....
Thu Aug 20 20:14:02 CDT 2009

20/08/09 @ 18:00 (-0700), thus spake Dr. Phillip M. Feldman:
> I have a 1-D array and would like to generate a list of indices for which a
> given condition is satisfied.  What is the cleanest way to do this?

you can do something like this:

numpy.arange(len(x))[x > 5]

it'll give you the indices of x where x is > 5.


More information about the NumPy-Discussion mailing list