Skip to content

read_csv ignores dtype for empty CSV files #14712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jluttine opened this issue Nov 22, 2016 · 0 comments
Closed

read_csv ignores dtype for empty CSV files #14712

jluttine opened this issue Nov 22, 2016 · 0 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions IO CSV read_csv, to_csv
Milestone

Comments

@jluttine
Copy link

Code Sample, a copy-pastable example if possible

>>> import io
>>> import pandas as pd
>>> pd.read_csv(io.StringIO('foo,bar'), header=0, dtype=np.float64).values
array([], shape=(0, 2), dtype=object)

Problem description

CSV reader doesn't respect the given dtype np.float64 but sets object dtype instead.

Expected Output

array([], shape=(0, 2), dtype=float64)

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Linux OS-release: 4.8.8-gnu-1 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.19.1
nose: 1.3.7
pip: 8.1.2
setuptools: 28.8.0
Cython: 0.25.1
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.4.8
patsy: None
dateutil: 2.6.0
pytz: 2016.7
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.5.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.5
sqlalchemy: 1.1.4
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None

gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 22, 2016
@jreback jreback added Bug Dtype Conversions Unexpected or buggy dtype conversions IO CSV read_csv, to_csv labels Nov 22, 2016
@jreback jreback added this to the Next Major Release milestone Nov 22, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 23, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 23, 2016
@jreback jreback modified the milestones: 0.20.0, Next Major Release Nov 23, 2016
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.19.2, 0.20.0 Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

3 participants