Open
Description
Pandas version checks
- I have checked that this issue has not already been reported.
- No issues mention
QUOTE_NOTNULL
- No issues mention
- I have confirmed this bug exists on the latest version of pandas.
- I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import csv
import pandas as pd
df = pd.DataFrame(
[[0, None, np.nan, pd.NA]],
columns=['a', 'b', 'c', 'd'])
print(df.to_csv(quoting=csv.QUOTE_NOTNULL, index=False))
Issue Description
All fields are quoted, even nulls.
"a","b","c","d"
"0","","",""
Expected Behavior
All nulls should be unquoted.
"a","b","c","d"
"0",,,
Another possibility I might have expected is only unquoting None
, as described in the csv
docs, but this doesn't make sense for Pandas IMHO since Pandas has multiple "NULL"s.
"a","b","c","d"
"0",,"",""
Installed Versions
INSTALLED VERSIONS
------------------
commit : b1c2ba793bb1f3d7001de41ca4c73377006b9e4d
python : 3.12.7
python-bits : 64
OS : Linux
OS-release : 5.4.0-200-generic
Version : #220-Ubuntu SMP Fri Sep 27 13:19:16 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fr_CA.UTF-8
LOCALE : fr_CA.UTF-8
pandas : 3.0.0.dev0+1729.gb1c2ba793b
numpy : 2.1.0.dev0+git20240403.e59c074
dateutil : 2.9.0.post0
pip : 24.2
Cython : None
sphinx : None
IPython : 8.22.2
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pytz : 2024.1
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None