[Numpy-discussion] min() of array containing NaN

Fabrice Silva silva@lma.cnrs-mrs...
Mon Aug 11 16:46:50 CDT 2008


Try nanmin function :

        $ python
        Python 2.5.2 (r252:60911, Jul 31 2008, 07:39:27) 
        [GCC 4.3.1] on linux2
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import numpy
        >>> numpy.__version__
        '1.1.0'
        >>> x = numpy.array([0,1,2,numpy.nan, 4, 5, 6])
        >>> x.min()
        4.0
        >>> numpy.nanmin(x)
        0.0

There lacks some nanmin method for array instances, i.e. one can not execute
        >>> x.nanmin()
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        AttributeError: 'numpy.ndarray' object has no attribute 'nanmin'
        
-- 
Fabrice Silva
LMA UPR CNRS 7051 - équipe S2M



More information about the Numpy-discussion mailing list