the difference of np.nan, np.NaN, np.NAN?
Dear all, is there any difference between np.nan, np.NaN and np.NAN? they really confuse me.... they are all Not a Number? In [75]: np.nan==np.NaN Out[75]: False In [77]: np.NaN==np.NAN Out[77]: False Thanks a lot, Chao -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************
Hi,
On Fri, Oct 14, 2011 at 4:33 AM, Chao YUE
Dear all,
is there any difference between np.nan, np.NaN and np.NAN? they really confuse me.... they are all Not a Number?
In [75]: np.nan==np.NaN Out[75]: False
In [77]: np.NaN==np.NAN Out[77]: False
The nan value is not equal to itself: In [70]: np.nan == np.nan Out[70]: False See: http://en.wikipedia.org/wiki/NaN But: In [71]: np.isnan(np.nan) Out[71]: True In [72]: np.isnan(np.NAN) Out[72]: True In [73]: np.isnan(np.NaN) Out[73]: True Best, Matthew
good answer....
2011/10/14 Matthew Brett
Hi,
On Fri, Oct 14, 2011 at 4:33 AM, Chao YUE
wrote: Dear all,
is there any difference between np.nan, np.NaN and np.NAN? they really confuse me.... they are all Not a Number?
In [75]: np.nan==np.NaN Out[75]: False
In [77]: np.NaN==np.NAN Out[77]: False
The nan value is not equal to itself:
In [70]: np.nan == np.nan Out[70]: False
See:
http://en.wikipedia.org/wiki/NaN
But:
In [71]: np.isnan(np.nan) Out[71]: True
In [72]: np.isnan(np.NAN) Out[72]: True
In [73]: np.isnan(np.NaN) Out[73]: True
Best,
Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************
2011/10/14 Matthew Brett
Hi,
On Fri, Oct 14, 2011 at 4:33 AM, Chao YUE
wrote: Dear all,
is there any difference between np.nan, np.NaN and np.NAN? they really confuse me.... they are all Not a Number?
In [75]: np.nan==np.NaN Out[75]: False
In [77]: np.NaN==np.NAN Out[77]: False
The nan value is not equal to itself:
In [70]: np.nan == np.nan Out[70]: False
See:
http://en.wikipedia.org/wiki/NaN
But:
In [71]: np.isnan(np.nan) Out[71]: True
In [72]: np.isnan(np.NAN) Out[72]: True
In [73]: np.isnan(np.NaN) Out[73]: True
Best,
Matthew
Also on my computer:
numpy.nan is numpy.NAN True numpy.nan is numpy.NaN True
So they really are the same. But you shouldn't rely on this (always use numpy.isnan to test for nan-ness). -=- Olivier
On Fri, Oct 14, 2011 at 11:53 AM, Olivier Delalleau
2011/10/14 Matthew Brett
Hi,
On Fri, Oct 14, 2011 at 4:33 AM, Chao YUE
wrote: Dear all,
is there any difference between np.nan, np.NaN and np.NAN? they really confuse me.... they are all Not a Number?
In [75]: np.nan==np.NaN Out[75]: False
In [77]: np.NaN==np.NAN Out[77]: False
The nan value is not equal to itself:
In [70]: np.nan == np.nan Out[70]: False
See:
http://en.wikipedia.org/wiki/NaN
But:
In [71]: np.isnan(np.nan) Out[71]: True
In [72]: np.isnan(np.NAN) Out[72]: True
In [73]: np.isnan(np.NaN) Out[73]: True
Best,
Matthew
Also on my computer:
numpy.nan is numpy.NAN True numpy.nan is numpy.NaN True
So they really are the same. But you shouldn't rely on this (always use numpy.isnan to test for nan-ness).
They are the same, just not equal to each other (or even to themselves). As for the different NaN names in numpy namespace, I think this is for historical reason (maybe because python itself used to print nan differently on different platforms, although this should not be the case anymore since python 2.6). David
participants (4)
-
Chao YUE
-
David Cournapeau
-
Matthew Brett
-
Olivier Delalleau