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

KeyError Iterating on empty HDFStore #12221

Closed
toobaz opened this issue Feb 3, 2016 · 2 comments
Closed

KeyError Iterating on empty HDFStore #12221

toobaz opened this issue Feb 3, 2016 · 2 comments
Labels
Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore
Milestone

Comments

@toobaz
Copy link
Member

toobaz commented Feb 3, 2016

list(pd.HDFStore("non_existing_store.hdf"))

should, I think, return [], instead it yields:

KeyError: 'No object named 0 in the file'
@toobaz toobaz changed the title KeyError Iterating on empty HDFStore gives unexpected error KeyError Iterating on empty HDFStore Feb 3, 2016
@jreback
Copy link
Contributor

jreback commented Feb 3, 2016

has nothing to do with an empty store, HDFStore is an iterable (e.g. has __getitem__ and __len__ defined), but not __iter__, so this essentially calls .get. I suppose it should just raise a better error message.

you are probably looking for .keys() (though I suppose __iter__ could just call that)

@jreback jreback added Difficulty Novice Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore labels Feb 3, 2016
@jreback jreback added this to the Next Major Release milestone Feb 3, 2016
@toobaz
Copy link
Member Author

toobaz commented Feb 3, 2016

Sorry, I was mislead by HDFStore().root being iterable. I will implement the __iter__ you suggest.

toobaz added a commit to toobaz/pandas that referenced this issue Feb 7, 2016
@toobaz toobaz mentioned this issue Feb 7, 2016
toobaz added a commit to toobaz/pandas that referenced this issue Feb 9, 2016
@jreback jreback modified the milestones: 0.18.0, Next Major Release Feb 11, 2016
cldy pushed a commit to cldy/pandas that referenced this issue Feb 11, 2016
closes pandas-dev#12221    HDFStore is not an iterator - but being iterable, it
can return an iterator of itself (i.e. of ``.keys()``).

Author: Pietro Battiston <me@pietrobattiston.it>

Closes pandas-dev#12253 from toobaz/iterable_hdfstore and squashes the following commits:

23bfb3a [Pietro Battiston] ENH: Make HDFStore iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants