[Numpy-discussion] Getting an array's indices when a given condition is true
Robert Kern
robert.kern at gmail.com
Sat Oct 18 23:13:16 EDT 2008
On Sat, Oct 18, 2008 at 22:00, Lane Brooks <lbrooks at mit.edu> wrote:
> If you want the indexes, check out the np.where command, e.g.
>
> idx = np.where(dat <= limit)
It's worth noting that where() confusingly has two modes of
functionality. This particular bit of functionality is also exposed
under the better-named nonzero() function. I prefer to use nonzero()
for this, and only use where() for its where(condition, value_if_true,
value_if_false) functionality.
--
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