[Numpy-discussion] argmin and argmax without nan
Dmitrey
tmp50 at ukr.net
Thu Mar 24 09:59:22 EDT 2011
2011/3/24 Dmitrey <
tmp50 at ukr.net >:
> hi,
> is there any way to get argmin and argmax of an array w/o nans?
> Currently I have
>>>> from numpy import *
>>>> argmax([10,nan,100])
> 1
>>>> argmin([10,nan,100])
> 1
> But it's not the values I would like to get.
>
> The walkaround I use: get all indeces of nans, replace them by -inf, get
> argmax, replace them by inf, get argmin.
> Is there any better way? (BTW, I invoke argmin/argmax along of a chosen
> axis)
> D.
In [3]: np.nanargmax([10, np.nan, 100])
Out[3]: 2
In [4]: np.nanargmin([10, np.nan, 100])
Out[4]: 0
Ralf
Thanks, I thought np.argnanmin should do that but those funcs were
absent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110324/51818a93/attachment.html>
More information about the NumPy-Discussion
mailing list