-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: add contextmanager to HDFStore (#8791) #8958
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
Conversation
this is fine pls add a release note in the enhancements section |
@jreback I've updated the docs. Not sure if I've got it right. |
pls squash, otherwise looks ok.
|
@jreback I've added warning that get_store is deprecated |
@@ -72,6 +72,7 @@ Enhancements | |||
- ``Timedelta`` arithmetic returns ``NotImplemented`` in unknown cases, allowing extensions by custom classes (:issue:`8813`). | |||
- ``Timedelta`` now supports arithemtic with ``numpy.ndarray`` objects of the appropriate dtype (numpy 1.8 or newer only) (:issue:`8884`). | |||
- Added ``Timedelta.to_timedelta64`` method to the public API (:issue:`8884`). | |||
- Added context manager to ``HDFStore`` (:issue:`8791`). get_store still works. Now with HDFStore('path') as store: should also close to store. get_store will be deprecated, warning added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take out the get_store still works.
.
On the deprecation, I don't know if it is needed to really deprecate it, maybe we could only do "deprecation by documentation" (-> keeping it as an alias (and indicate this in the docstring of |
@jorisvandenbossche @jreback so I've made those changes. Sorry misunderstood that you guys wanted it deprecated. |
ok, pls add a release note (put in enhancements section) |
@@ -1288,6 +1267,9 @@ def _read_group(self, group, **kwargs): | |||
return s.read(**kwargs) | |||
|
|||
|
|||
get_store = HDFStore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add here something to the docstring of get_store
that is is an alias of HDFStore -> better to use that.
You can use pd.util.decorators.Appender for that. Something like:
get_store = Appender("Backwards compatible alias for ``HDFStore``", join='\n')(HDFStore)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added that now.
instead of having to use with get_store('file.h5') as store: store.keys() now we can do with HDFStore('file.h5') as store: store.keys()
looks ok to me. ping on green. |
@jreback it's green |
@vikram thanks! |
Added a context manager to HDFStore
closes #8791