From d9e00d2ac0803c561c9f7af1131f586aecfb8113 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 7 Apr 2017 11:21:04 -0400 Subject: [PATCH] DEPR: deprecate pd.get_store as not api consistent and cluttering (#15940) --- doc/source/whatsnew/v0.20.0.txt | 3 ++- pandas/io/pytables.py | 7 +++++++ pandas/tests/api/test_api.py | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.20.0.txt b/doc/source/whatsnew/v0.20.0.txt index 21b259e7663ba..31b0efa14a44d 100644 --- a/doc/source/whatsnew/v0.20.0.txt +++ b/doc/source/whatsnew/v0.20.0.txt @@ -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: diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 9b525b76b0f17..802f460ecba07 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -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) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 7d1308d67668e..7301c87026114 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -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 @@ -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', @@ -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): @@ -140,6 +141,7 @@ def test_deprecation_access_obj(self): class TestTopLevelDeprecations(tm.TestCase): + # top-level API deprecations # GH 13790 @@ -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):