Skip to content

read_table with dtype=object and an int converter still returns float64 if NaN present #14558

Closed
@radekholy24

Description

@radekholy24

A small, complete example of the issue

>>> import io, pandas
>>> csvfile = io.StringIO('a\nN/A\n1\n')
>>> converters = {'a': lambda x: float('nan') if x == 'N/A' else int(x)}
>>> pandas.read_table(csvfile, dtype=object, converters=converters)
     a
0  NaN
1  1.0

Expected Output

     a
0  NaN
1    1

Output of pd.show_versions()

pandas: 0.19.0
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.19.0
nose: None
pip: 7.1.0
setuptools: 18.0.1
Cython: None
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions