-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: to_hdf and HDFStore raise KeyError for DataFrame subclasses #33748
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
this is possible but would need a community PR |
Well, I'd be happy to change line 1528 of |
I have run into a similar error by just appending pandas chunk dfs to an HDF5 file.
I didn't find any solutions in the issues. This issue post is the most relevant one. Pls help debug it. Thanks! |
That doesn't look like it's the same issue. This thread is specifically about storing subclasses of DataFrame to HDF. |
[x ] I have checked that this issue has not already been reported.
[x ] I have confirmed this bug exists on the latest version of pandas.
Code Sample, a copy-pastable example
Problem description
to_hdf()
andHDFStore.put()
fail for DataFrame subclasses.This happens because in
pandas/io/pytables.py
in_create_storer
line 1578 (or thereabouts), the_TYPE_MAP
is accessed bytype()
, whereas upon_create_storer
entry, the check is done usingisinstance()
.Expected Output
The check upon entry of
_create_storer
should at least be consistent with the way_TYPE_MAP
is accessed. So if the choice is not to support writing DataFrame subclasses to HDF, instead of aKeyError
, aTypeError("value must be None, Series, or DataFrame")
should be raised.But ideally, storing subclasses of DataFrame to HDF should be supported.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.10.final.0
python-bits : 64
OS : Linux
OS-release : 4.14.111-1.el7.centos.x86_64
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.3
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.1.3.post20200325
Cython : None
pytest : 5.4.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 7.10.2
pandas_datareader: None
bs4 : 4.8.2
bottleneck : None
fastparquet : 0.3.2
gcsfs : None
lxml.etree : None
matplotlib : 3.1.1
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.1
pyxlsb : None
s3fs : 0.4.0
scipy : 1.2.1
sqlalchemy : 1.3.11
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : 0.46.0
The text was updated successfully, but these errors were encountered: