Skip to content

Commit

Permalink
DEPR: deprecate pd.get_store as not api consistent and cluttering (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Apr 7, 2017
1 parent f478e4f commit d9e00d2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,14 @@ Deprecations
- importing ``concat`` from ``pandas.tools.merge`` has been deprecated in favor of imports from the ``pandas`` namespace. This should only affect explict imports (:issue:`15358`)
- ``Series/DataFrame/Panel.consolidate()`` been deprecated as a public method. (:issue:`15483`)
- The ``as_indexer`` keyword of ``Series.str.match()`` has been deprecated (ignored keyword) (:issue:`15257`).
- The following top-level pandas functions have been deprecated and will be removed in a future version (:issue:`13790`)
- The following top-level pandas functions have been deprecated and will be removed in a future version (:issue:`13790`, :issue:`15940`)

* ``pd.pnow()``, replaced by ``Period.now()``
* ``pd.Term``, is removed, as it is not applicable to user code. Instead use in-line string expressions in the where clause when searching in HDFStore
* ``pd.Expr``, is removed, as it is not applicable to user code.
* ``pd.match()``, is removed.
* ``pd.groupby()``, replaced by using the ``.groupby()`` method directly on a ``Series/DataFrame``
* ``pd.get_store()``, replaced by a direct call to ``pd.HDFStore(...)``

.. _whatsnew_0200.prior_deprecations:

Expand Down
7 changes: 7 additions & 0 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,13 @@ def _read_group(self, group, **kwargs):
def get_store(path, **kwargs):
""" Backwards compatible alias for ``HDFStore``
"""
warnings.warn(
"get_store is deprecated and be "
"removed in a future version\n"
"HDFStore(path, **kwargs) is the replacement",
FutureWarning,
stacklevel=6)

return HDFStore(path, **kwargs)


Expand Down
16 changes: 14 additions & 2 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from warnings import catch_warnings

import pytest
import pandas as pd
from pandas import api
from pandas.util import testing as tm
Expand Down Expand Up @@ -63,7 +64,7 @@ class TestPDApi(Base, tm.TestCase):
# top-level functions
funcs = ['bdate_range', 'concat', 'crosstab', 'cut',
'date_range', 'eval',
'factorize', 'get_dummies', 'get_store',
'factorize', 'get_dummies',
'infer_freq', 'isnull', 'lreshape',
'melt', 'notnull', 'offsets',
'merge', 'merge_ordered', 'merge_asof',
Expand Down Expand Up @@ -102,7 +103,7 @@ class TestPDApi(Base, tm.TestCase):
'rolling_median', 'rolling_min', 'rolling_quantile',
'rolling_skew', 'rolling_std', 'rolling_sum',
'rolling_var', 'rolling_window', 'ordered_merge',
'pnow', 'match', 'groupby']
'pnow', 'match', 'groupby', 'get_store']

def test_api(self):

Expand Down Expand Up @@ -140,6 +141,7 @@ def test_deprecation_access_obj(self):


class TestTopLevelDeprecations(tm.TestCase):

# top-level API deprecations
# GH 13790

Expand Down Expand Up @@ -168,6 +170,16 @@ def test_groupby(self):
check_stacklevel=False):
pd.groupby(pd.Series([1, 2, 3]), [1, 1, 1])

# GH 15940

def test_get_store(self):
pytest.importorskip('tables')
with tm.ensure_clean() as path:
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
s = pd.get_store(path)
s.close()


class TestJson(tm.TestCase):

Expand Down

0 comments on commit d9e00d2

Please sign in to comment.