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

Robert Kern robert.kern@gmail....
Thu Aug 20 20:05:48 CDT 2009


On Thu, Aug 20, 2009 at 18:00, Dr. Phillip M.
Feldman<pfeldman@verizon.net> wrote:
>
> 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?

numpy.nonzero(condition)[0]

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list