Skip to content
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

BUG: HDFStore.get_storer.shape returns (1, #) when the table has 0 row #37235

Open
chris0411 opened this issue Oct 19, 2020 · 0 comments
Open
Labels
Bug IO HDF5 read_hdf, HDFStore

Comments

@chris0411
Copy link

import pandas as pd

h5file = r'D:\test.h5'
df = pd.DataFrame(range(10)).iloc[0:0]  # 0 row, 1 column
df.to_hdf(h5file, key='abc', format='f')
h5 = pd.HDFStore(h5file)

print(h5.get_storer('abc').shape)  # get [1, 1] instead of [0, 1]

Problem description

I expect HDFStore.get_storer.shape to give [0, #] where there's 0 row in an HDF file, but it gives [1, #].

This happens in fixed format tables.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : db08276
python : 3.7.9.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.1.3
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 50.3.0.post20201006
Cython : 0.29.21
pytest : 6.1.1
hypothesis : 5.37.1
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.3
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.19
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.51.2

@chris0411 chris0411 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 19, 2020
@chris0411 chris0411 changed the title BUG: HDFStore.get_storer.shape returns (1, #) where the table is empty BUG: HDFStore.get_storer.shape returns (1, #) when the table is empty Oct 19, 2020
@chris0411 chris0411 changed the title BUG: HDFStore.get_storer.shape returns (1, #) when the table is empty BUG: HDFStore.get_storer.shape returns (1, #) when the table has 0 row Oct 19, 2020
@mroeschke mroeschke added IO HDF5 read_hdf, HDFStore and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

No branches or pull requests

2 participants