[Numpy-discussion] efficient way to get first index of first masked/non-masked value in a masked array
robert.kern at gmail.com
Fri Dec 1 16:13:41 CST 2006
Matt Knox wrote:
> all I can come up with is dumb brute force methods by iterating through all the values. Anyone got any tricks I can use?
import numpy as np
idx = np.where(m.mask)
if len(idx) != 0:
raise ValueError("no masked data")
first_unmasked() is left as an exercise for the reader.
"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