-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Error reading an empty CSV with known column names and dtype 'category' #14606
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
Comments
Thanks for the report. You can construct an empty In [5]: pd.Categorical([])
Out[5]: [], Categories (0, float64): [] or
|
you can specify the dtype so think / maybe should be object (shouldn't matter if u union as it will coerce I think, maybe need to check that) |
could also give it np.empty(0, dtype='object') instead of an empty list to the Categorical constructor |
Issue pandas-dev#14606 was fixed by PR pandas-dev#14717, adding one more specific test to confirm this
Issue pandas-dev#14606 was fixed by PR pandas-dev#14717, adding one more specific test to confirm this
…andas-dev#14752) Issue pandas-dev#14606 was fixed by PR pandas-dev#14717, adding one more specific test to confirm this
Hello, I've found a corner case where specifying
category
dtypes inpd.read_csv
causes an error when it ought to return an empty dataframe.A small, complete example of the issue
Expected Output
Appears the problem is in
_get_empty_meta()
where thecategory
dtype is passed along tonp.empty
. I don't know the idiomatic way to construct an empty Categorical series but that is what needs to happen.Output of
pd.show_versions()
pandas: 0.19.1
nose: None
pip: 8.1.1
setuptools: 20.3
Cython: 0.24.1
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.3
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: 0.6.7.None
psycopg2: 2.6.1 (dt dec pq3 ext)
jinja2: 2.8
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: