[Numpy-discussion] Finding indices for all rows which contain nan (or anything else)
Webb Sprague
webb.sprague at gmail.com
Thu Jul 13 14:42:30 CDT 2006
Does anyone have some vectorized code that pulls out all the row
indices for any row which has an nan (or a number less than 1 or
whatever). I want to subsequently be able to perform an operation
with all the good rows. See the imaginary code below.
a = numpy.array([[1,2],[nan,1], [2,3]])
is_row_nan(a) == array([1])
ii = numpy.negative(is_row_nan(a))
a[ii,:] # these are the ones I want. Hopefully this is array([[1,2],[2,3]])
I can imagine doing this with a loop or with (maybe) some fancy set
union stuff, but I am at a loss for vectorized versions.
Thanks
More information about the Numpy-discussion
mailing list