[Numpy-discussion] argmin and argmax

Keith Goodman kwgoodman@gmail....
Sat Jul 11 09:09:57 CDT 2009


On Sat, Jul 11, 2009 at 3:20 AM, f0X_in_s0X<sidhant@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   :)


More information about the NumPy-Discussion mailing list