You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example, the column of boolean data contains a missing value. If I read the column as booleans (either explicitly via dtype or by allowing pandas to infer the type), then the missing value is given as NaN, as it should be. If I force the column type to be a float (or an integer) via the dtype argument to read_csv, then the missing value is given as 1.0, the same as True.
Code Sample, a copy-pastable example if possible
In
pandas
v0.20.2, the following codegives output
Problem description
In this example, the column of boolean data contains a missing value. If I read the column as booleans (either explicitly via
dtype
or by allowingpandas
to infer the type), then the missing value is given asNaN
, as it should be. If I force the column type to be a float (or an integer) via thedtype
argument toread_csv
, then the missing value is given as1.0
, the same asTrue
.Expected Output
The output of
should be the same as the output of
which is
I.e., the missing value in the input CSV should be cast to
NaN
rather than1.0
.Output of
pd.show_versions()
------------------
commit: None python: 3.6.0.final.0 python-bits: 64 OS: Darwin OS-release: 15.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8
pandas: 0.20.2
pytest: 3.0.7
pip: 9.0.1
setuptools: 33.1.1.post20170320
Cython: 0.25.2
numpy: 1.13.0
scipy: 0.19.0
xarray: None
IPython: 6.0.0
sphinx: 1.5.5
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.5.3
html5lib: 0.999
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: