Not a Number
Not a Number (NaN) are a special state that indicates an undefined value. NaNs are only defined for floating point variables.
The following python functions exists and can be used to test if a value is NaN:
isnan()
isfinite()
The following mathematical functions exists that can be used with arrays that contain NaNs:
nansum()
nanmax()
nanmin()
scipy.stats.nanmean()
scipy.stats.nanstd()
scipy.stats.nanmedian()
Example
In [23]: a=arange(4,dtype=float) In [24]: a[1]=nan In [25]: i=isfinite(a) In [26]: a Out[26]: array([ 0., NaN, 2., 3.]) In [27]: i Out[27]: array([ True, False, True, True], dtype=bool) In [28]: a[i] Out[28]: array([ 0., 2., 3.]) In [29]: mean(a[i]) Out[29]: 1.6666666666666667 In [30]: mean(a) Out[30]: nan In [31]: import scipy.stats In [32]: scipy.stats.nanmean(a) Out[32]: 1.6666666666666667