From b9b5d8b6a35a20012caf7fa13dca51a5d7987169 Mon Sep 17 00:00:00 2001 From: Tom Bird Date: Thu, 15 Sep 2016 17:44:43 +0100 Subject: [PATCH 1/3] DOC: #14195. to_csv warns regarding quoting behaviour for floats Added a small warning that if `float_format` is set then floats will be quoted even if csv.QUOTE_NONNUMERIC is set --- pandas/core/frame.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 1cc689528caaa..0d2a6d8c7a5fd 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1345,7 +1345,9 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None, The newline character or character sequence to use in the output file quoting : optional constant from csv module - defaults to csv.QUOTE_MINIMAL + defaults to csv.QUOTE_MINIMAL. If you have set a `float_format` + then floats are comverted to strings and thus csv.QUOTE_NONNUMERIC + will treat them as non-numeric quotechar : string (length 1), default '\"' character used to quote fields doublequote : boolean, default True From 6af06c320479efe98ef70df0d388a3b1d4179495 Mon Sep 17 00:00:00 2001 From: Tom Bird Date: Thu, 15 Sep 2016 19:01:19 +0100 Subject: [PATCH 2/3] DOC: #14195. to_csv warns regarding quoting behaviour for floats Added a small warning that if 'float_format' is set then floats will be quoted even if csv.QUOTE_NONNUMERIC is set --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 0d2a6d8c7a5fd..0b446c26c977d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1346,7 +1346,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None, file quoting : optional constant from csv module defaults to csv.QUOTE_MINIMAL. If you have set a `float_format` - then floats are comverted to strings and thus csv.QUOTE_NONNUMERIC + then floats are comverted to strings and thus csv.QUOTE_NONNUMERIC will treat them as non-numeric quotechar : string (length 1), default '\"' character used to quote fields From f3df0d90627f6cbe2c51496c3ab0ac1fcca120bb Mon Sep 17 00:00:00 2001 From: Tom Bird Date: Thu, 15 Sep 2016 19:13:50 +0100 Subject: [PATCH 3/3] DOC: #14195. to_csv warns regarding quoting behaviour for floats Added a small warning that if float_format is set then floats will be quoted even if csv.QUOTE_NONNUMERIC is set --- doc/source/io.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index d436fa52918d3..3661d4b4cdff7 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -1481,7 +1481,7 @@ function takes a number of arguments. Only the first is required. - ``encoding``: a string representing the encoding to use if the contents are non-ASCII, for python versions prior to 3 - ``line_terminator``: Character sequence denoting line end (default '\\n') - - ``quoting``: Set quoting rules as in csv module (default csv.QUOTE_MINIMAL) + - ``quoting``: Set quoting rules as in csv module (default csv.QUOTE_MINIMAL). Note that if you have set a `float_format` then floats are converted to strings and csv.QUOTE_NONNUMERIC will treat them as non-numeric - ``quotechar``: Character used to quote fields (default '"') - ``doublequote``: Control quoting of ``quotechar`` in fields (default True) - ``escapechar``: Character used to escape ``sep`` and ``quotechar`` when