From d74b306fb97c5f4c3bba5ccf5ecc7fac8e711ae4 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 7 Apr 2017 10:01:32 -0400 Subject: [PATCH] DEPR: deprecate pd.get_store as not api consistent and cluttering --- doc/source/whatsnew/v0.20.0.txt | 1 + pandas/io/pytables.py | 7 +++++++ pandas/tests/api/test_api.py | 13 +++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.20.0.txt b/doc/source/whatsnew/v0.20.0.txt index cb9e2496757efe..010a078918a08f 100644 --- a/doc/source/whatsnew/v0.20.0.txt +++ b/doc/source/whatsnew/v0.20.0.txt @@ -920,6 +920,7 @@ Deprecations * ``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 9b525b76b0f171..802f460ecba07a 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 7d1308d67668e5..20242e570a42af 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): @@ -168,6 +169,14 @@ def test_groupby(self): check_stacklevel=False): pd.groupby(pd.Series([1, 2, 3]), [1, 1, 1]) + 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):