Skip to content

Commit 5c83923

Browse files
author
Caleb Epstein
committed
Add -NaN and -nan to default NA values
1 parent fcfaa7d commit 5c83923

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

doc/source/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ the corresponding equivalent values will also imply a missing value (in this cas
575575

576576
To completely override the default values that are recognized as missing, specify ``keep_default_na=False``.
577577
The default ``NaN`` recognized values are ``['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A','N/A', 'NA',
578-
'#NA', 'NULL', 'NaN', 'nan']``.
578+
'#NA', 'NULL', 'NaN', '-NaN', 'nan', '-nan']``.
579579

580580
.. code-block:: python
581581

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ API Changes
6464
- ``autocorrelation_plot`` now accepts ``**kwargs``. (:issue:`5623`)
6565
- ``convert_objects`` now accepts a ``convert_timedeltas='coerce'`` argument to allow forced dtype conversion of
6666
timedeltas (:issue:`5458`,:issue:`5689`)
67+
- Add ``-NaN`` and ``-nan`` to the default set of NA values
68+
(:issue:`5952`). See :ref:`NA Values <io.na_values>`.
6769

6870
Experimental Features
6971
~~~~~~~~~~~~~~~~~~~~~

doc/source/v0.13.1.txt

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ There are several new or updated docs sections including:
1818
API changes
1919
~~~~~~~~~~~
2020

21+
- Add ``-NaN`` and ``-nan`` to the default set of NA values (:issue:`5952`).
22+
See :ref:`NA Values <io.na_values>`.
23+
2124
Prior Version Deprecations/Changes
2225
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2326

pandas/io/parsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def read_fwf(filepath_or_buffer, colspecs='infer', widths=None, **kwds):
449449
# '1.#INF','-1.#INF', '1.#INF000000',
450450
_NA_VALUES = set([
451451
'-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A', 'N/A', 'NA', '#NA',
452-
'NULL', 'NaN', 'nan', ''
452+
'NULL', 'NaN', '-NaN', 'nan', '-nan', ''
453453
])
454454

455455

pandas/io/tests/test_parsers.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import pandas.tseries.tools as tools
3434

3535
from numpy.testing.decorators import slow
36+
from numpy.testing import assert_array_equal
3637

3738
from pandas.parser import OverflowError
3839

@@ -685,8 +686,8 @@ def test_non_string_na_values(self):
685686
def test_default_na_values(self):
686687
_NA_VALUES = set(['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN',
687688
'#N/A','N/A', 'NA', '#NA', 'NULL', 'NaN',
688-
'nan', ''])
689-
689+
'nan', '-NaN', '-nan', ''])
690+
assert_array_equal (_NA_VALUES, parsers._NA_VALUES)
690691
nv = len(_NA_VALUES)
691692
def f(i, v):
692693
if i == 0:

0 commit comments

Comments
 (0)