Skip to content

BUG: A zero length series written to HDF cannot be read back. #4708

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
prossahl opened this issue Aug 30, 2013 · 0 comments · Fixed by #4709
Closed

BUG: A zero length series written to HDF cannot be read back. #4708

prossahl opened this issue Aug 30, 2013 · 0 comments · Fixed by #4709
Labels
Bug IO HDF5 read_hdf, HDFStore
Milestone

Comments

@prossahl
Copy link
Contributor

This happens with and empty series with numpy arrays for both the values and the index.

>>> import pandas as pd
>>> import numpy as np
>>> 
>>> with pd.get_store('foo.h5') as store:
...     s = pd.Series(np.array([], dtype=np.int64), index=np.array([], dtype=np.int64))
...     store['s'] = s
...     s = store['s']
... 
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/io/pytables.py", line 349, in __getitem__
    return self.get(key)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/io/pytables.py", line 507, in get
    return self._read_group(group)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/io/pytables.py", line 1093, in _read_group
    return s.read(**kwargs)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/io/pytables.py", line 2247, in read
    return Series(values, index=index, name=self.name)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/core/series.py", line 657, in __init__
    data = SingleBlockManager(data, index, fastpath=True)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/core/internals.py", line 2942, in __init__
    block = make_block(block, axis, axis, ndim=1, fastpath=True)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/core/internals.py", line 1535, in make_block
    return klass(values, items, ref_items, ndim=ndim, fastpath=fastpath, placement=placement)
  File "/users/is/pross/workspace/pandas/git/pandas/pandas/core/internals.py", line 62, in __init__
    % (len(items), len(values)))
ValueError: Wrong number of items passed 1, indices imply 0

I have fixed this locally and will put in a PR.

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

Successfully merging a pull request may close this issue.

1 participant