[Numpy-discussion] argmin and argmax

Keith Goodman kwgoodman at gmail.com
Sat Jul 11 10:12:44 EDT 2009


On Sat, Jul 11, 2009 at 7:09 AM, Keith Goodman<kwgoodman at gmail.com> wrote:
> On Sat, Jul 11, 2009 at 3:20 AM, f0X_in_s0X<sidhant at gmail.com> wrote:
>>
>> Do argmin and argmax skip nan values? I cant find it anywhere in the numpy
>> documentation.
>>
>> In any case, if I want to find max and min values in an array that may
>> contain nan values also, what would the be the most efficient way to do
>> that? Any pointers??
>
>>> x = np.array([np.nan, 1, 2, np.nan])
>>> x.argmax()
>   0   :(
>>> x.argmin()
>   0   :(
>>> np.__version__
>   '1.2.1'
>>>
>>> np.nanargmax(x)
>   2   :)
>>> np.nanargmin(x)
>   1   :)

Oh, you only want the values? Then take a look at np.nanmax and np.nanmin.



More information about the NumPy-Discussion mailing list