Pandas: na_rep Truncated With Int64 dtype in to_csv

Created on 3 Feb 2019  路  1Comment  路  Source: pandas-dev/pandas

Code Sample

df = pd.DataFrame({"c": [float('nan')]*3})
df = df.astype("Int64")

print(df.to_csv(index=False, na_rep='mynull'))
c
myn
myn
myn

Problem description

I'd expect na_rep to be always respected, with all column types.

Expected Output

print(df.to_csv(index=False, na_rep='mynull'))
c
mynull
mynull
mynull

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.4.final.0
python-bits: 32
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: pt_BR.cp1252

pandas: 0.24.0
pytest: None
pip: 9.0.1
setuptools: 28.8.0
Cython: None
numpy: 1.16.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Bug ExtensionArray IO CSV Output-Formatting

Most helpful comment

Thanks for the report - that does look rather strange. Investigation and PRs are always welcome!

>All comments

Thanks for the report - that does look rather strange. Investigation and PRs are always welcome!

Was this page helpful?
0 / 5 - 0 ratings