NaN can be used as a numeric value for mathematical operations, and None cannot (or at least should not).
NaN is a numeric value defined in IEEE 754 floating point . None is Python's internal python ( NoneType ), and in this context it will be more like "nonexistent" or "empty" than "numerically invalid".
The main "symptom" of this is that if you execute, say, the average value or the sum on an array containing NaN, even in one, you get NaN as a result ...
On the other hand, you cannot perform math operations using None as an operand.
Thus, depending on the case, you can use None as a way of telling your algorithm not to consider invalid or nonexistent values in the calculations. This would mean that the algorithm must check each value to see if it is None .
Numpy has some features to avoid NaN values, to foul your results, like nansum and nan_to_num .
heltonbiker Jul 08 '13 at 19:16 2013-07-08 19:16
source share