From 5c839238c33bc8cc5030e9a84efc23f194a47853 Mon Sep 17 00:00:00 2001 From: Caleb Epstein Date: Wed, 22 Jan 2014 12:28:45 -0500 Subject: [PATCH] Add -NaN and -nan to default NA values --- doc/source/io.rst | 2 +- doc/source/release.rst | 2 ++ doc/source/v0.13.1.txt | 3 +++ pandas/io/parsers.py | 2 +- pandas/io/tests/test_parsers.py | 5 +++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index cba81a8b39600..fdad28688b7c6 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -575,7 +575,7 @@ the corresponding equivalent values will also imply a missing value (in this cas To completely override the default values that are recognized as missing, specify ``keep_default_na=False``. The default ``NaN`` recognized values are ``['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A','N/A', 'NA', -'#NA', 'NULL', 'NaN', 'nan']``. +'#NA', 'NULL', 'NaN', '-NaN', 'nan', '-nan']``. .. code-block:: python diff --git a/doc/source/release.rst b/doc/source/release.rst index 3cee4473aab66..e1325c676340e 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -64,6 +64,8 @@ API Changes - ``autocorrelation_plot`` now accepts ``**kwargs``. (:issue:`5623`) - ``convert_objects`` now accepts a ``convert_timedeltas='coerce'`` argument to allow forced dtype conversion of timedeltas (:issue:`5458`,:issue:`5689`) + - Add ``-NaN`` and ``-nan`` to the default set of NA values + (:issue:`5952`). See :ref:`NA Values `. Experimental Features ~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/source/v0.13.1.txt b/doc/source/v0.13.1.txt index 08c8eb76caaf8..33dc92343427b 100644 --- a/doc/source/v0.13.1.txt +++ b/doc/source/v0.13.1.txt @@ -18,6 +18,9 @@ There are several new or updated docs sections including: API changes ~~~~~~~~~~~ +- Add ``-NaN`` and ``-nan`` to the default set of NA values (:issue:`5952`). + See :ref:`NA Values `. + Prior Version Deprecations/Changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 796475aa24a58..689d4aab48758 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -449,7 +449,7 @@ def read_fwf(filepath_or_buffer, colspecs='infer', widths=None, **kwds): # '1.#INF','-1.#INF', '1.#INF000000', _NA_VALUES = set([ '-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A', 'N/A', 'NA', '#NA', - 'NULL', 'NaN', 'nan', '' + 'NULL', 'NaN', '-NaN', 'nan', '-nan', '' ]) diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py index f04c055692386..76006507be524 100644 --- a/pandas/io/tests/test_parsers.py +++ b/pandas/io/tests/test_parsers.py @@ -33,6 +33,7 @@ import pandas.tseries.tools as tools from numpy.testing.decorators import slow +from numpy.testing import assert_array_equal from pandas.parser import OverflowError @@ -685,8 +686,8 @@ def test_non_string_na_values(self): def test_default_na_values(self): _NA_VALUES = set(['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A','N/A', 'NA', '#NA', 'NULL', 'NaN', - 'nan', '']) - + 'nan', '-NaN', '-nan', '']) + assert_array_equal (_NA_VALUES, parsers._NA_VALUES) nv = len(_NA_VALUES) def f(i, v): if i == 0: