Skip to content

Commit ee374ee

Browse files
tom-birdjorisvandenbossche
authored andcommitted
DOC: to_csv warns regarding quoting behaviour for floats #14195 (#14228)
Added a small warning that if `float_format` is set then floats will be quoted even if csv.QUOTE_NONNUMERIC is set
1 parent 61bb4ed commit ee374ee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

doc/source/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ function takes a number of arguments. Only the first is required.
14811481
- ``encoding``: a string representing the encoding to use if the contents are
14821482
non-ASCII, for python versions prior to 3
14831483
- ``line_terminator``: Character sequence denoting line end (default '\\n')
1484-
- ``quoting``: Set quoting rules as in csv module (default csv.QUOTE_MINIMAL)
1484+
- ``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
14851485
- ``quotechar``: Character used to quote fields (default '"')
14861486
- ``doublequote``: Control quoting of ``quotechar`` in fields (default True)
14871487
- ``escapechar``: Character used to escape ``sep`` and ``quotechar`` when

pandas/core/frame.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,9 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
13451345
The newline character or character sequence to use in the output
13461346
file
13471347
quoting : optional constant from csv module
1348-
defaults to csv.QUOTE_MINIMAL
1348+
defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`
1349+
then floats are comverted to strings and thus csv.QUOTE_NONNUMERIC
1350+
will treat them as non-numeric
13491351
quotechar : string (length 1), default '\"'
13501352
character used to quote fields
13511353
doublequote : boolean, default True

0 commit comments

Comments
 (0)