read_csv ignores dtype for empty CSV files · Issue #14712 · pandas-dev/pandas (original) (raw)
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