[Numpy-discussion] What is the different between nanmin and min ?

David Cournapeau david@ar.media.kyoto-u.ac...
Tue Jul 17 06:31:04 CDT 2007


Matthieu Brucher wrote:
> Hi,
>
> I encountered cases where numpy.min() returned nan when the first and 
> the last values were nan. Didn't know of nanmin(), but I'll use them now !
Mmh, interesting. Indeed, a quick test shows that as long as the last 
value of a rank 1 array is not Nan, min ignore nan.

import numpy
a = 0.1 * numpy.arange(10)
numpy.min(a)
a[:9] = numpy.nan
numpy.min(a) # ignore Nan
a = 0.1 * numpy.arange(10)
a[-1] = numpy.nan
numpy.min(a) # Does not ignore Nan

cheers,

David


More information about the Numpy-discussion mailing list