Skip to content

Commit 67c908d

Browse files
committed
CLN: Cleanup top-level pandas namespace
Drops the following: * pd.pnow * pd.match * pd.groupby * pd.get_store * pd.Expr * pd.Term xref pandas-devgh-15538. xref pandas-devgh-15940.
1 parent f662c5f commit 67c908d

File tree

9 files changed

+6
-140
lines changed

9 files changed

+6
-140
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ Removal of prior version deprecations/changes
943943
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats`` (:issue:`14645`)
944944
- Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`)
945945
- Removed the ``pandas.formats.style`` shim for :class:`pandas.io.formats.style.Styler` (:issue:`16059`)
946+
- :func:`pandas.pnow`, :func:`pandas.match`, :func:`pandas.groupby`, :func:`pd.get_store`, ``pd.Expr``, and ``pd.Term`` have been removed (:issue:`15538`, :issue:`15940`)
946947
- :meth:`Categorical.searchsorted` and :meth:`Series.searchsorted` have renamed the ``v`` argument to ``value`` (:issue:`14645`)
947948
- :meth:`TimedeltaIndex.searchsorted`, :meth:`DatetimeIndex.searchsorted`, and :meth:`PeriodIndex.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`)
948949
- Removal of the previously deprecated module ``pandas.json`` (:issue:`19944`)

pandas/core/api.py

+1-22
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
MultiIndex, IntervalIndex,
1515
TimedeltaIndex, DatetimeIndex,
1616
PeriodIndex, NaT)
17-
from pandas.core.indexes.period import Period, period_range, pnow
17+
from pandas.core.indexes.period import Period, period_range
1818
from pandas.core.indexes.timedeltas import Timedelta, timedelta_range
1919
from pandas.core.indexes.datetimes import Timestamp, date_range, bdate_range
2020
from pandas.core.indexes.interval import Interval, interval_range
@@ -36,27 +36,6 @@
3636
describe_option, option_context, options)
3737

3838

39-
# deprecation, xref #13790
40-
def match(*args, **kwargs):
41-
42-
import warnings
43-
warnings.warn("pd.match() is deprecated and will be removed "
44-
"in a future version",
45-
FutureWarning, stacklevel=2)
46-
from pandas.core.algorithms import match
47-
return match(*args, **kwargs)
48-
49-
50-
def groupby(*args, **kwargs):
51-
import warnings
52-
53-
warnings.warn("pd.groupby() is deprecated and will be removed; "
54-
"Please use the Series.groupby() or "
55-
"DataFrame.groupby() methods",
56-
FutureWarning, stacklevel=2)
57-
return args[0].groupby(*args[1:], **kwargs)
58-
59-
6039
# Deprecation: xref gh-16747
6140
class TimeGrouper(object):
6241

pandas/core/computation/api.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
# flake8: noqa
22

33
from pandas.core.computation.eval import eval
4-
5-
6-
# deprecation, xref #13790
7-
def Expr(*args, **kwargs):
8-
import warnings
9-
10-
warnings.warn("pd.Expr is deprecated as it is not "
11-
"applicable to user code",
12-
FutureWarning, stacklevel=2)
13-
from pandas.core.computation.expr import Expr
14-
return Expr(*args, **kwargs)

pandas/core/indexes/period.py

-8
Original file line numberDiff line numberDiff line change
@@ -982,14 +982,6 @@ def base(self):
982982
PeriodIndex._add_datetimelike_methods()
983983

984984

985-
def pnow(freq=None):
986-
# deprecation, xref #13790
987-
warnings.warn("pd.pnow() and pandas.core.indexes.period.pnow() "
988-
"are deprecated. Please use Period.now()",
989-
FutureWarning, stacklevel=2)
990-
return Period.now(freq=freq)
991-
992-
993985
def period_range(start=None, end=None, periods=None, freq='D', name=None):
994986
"""
995987
Return a fixed frequency PeriodIndex, with day (calendar) as the default

pandas/io/api.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,7 @@
1414
from pandas.io.parquet import read_parquet
1515
from pandas.io.parsers import read_csv, read_fwf, read_table
1616
from pandas.io.pickle import read_pickle, to_pickle
17-
from pandas.io.pytables import HDFStore, get_store, read_hdf
17+
from pandas.io.pytables import HDFStore, read_hdf
1818
from pandas.io.sas import read_sas
1919
from pandas.io.sql import read_sql, read_sql_query, read_sql_table
2020
from pandas.io.stata import read_stata
21-
22-
23-
# deprecation, xref #13790
24-
def Term(*args, **kwargs):
25-
import warnings
26-
27-
warnings.warn("pd.Term is deprecated as it is not "
28-
"applicable to user code. Instead use in-line "
29-
"string expressions in the where clause when "
30-
"searching in HDFStore",
31-
FutureWarning, stacklevel=2)
32-
from pandas.io.pytables import Term
33-
return Term(*args, **kwargs)

pandas/io/pytables.py

-13
Original file line numberDiff line numberDiff line change
@@ -1416,19 +1416,6 @@ def _read_group(self, group, **kwargs):
14161416
return s.read(**kwargs)
14171417

14181418

1419-
def get_store(path, **kwargs):
1420-
""" Backwards compatible alias for ``HDFStore``
1421-
"""
1422-
warnings.warn(
1423-
"get_store is deprecated and be "
1424-
"removed in a future version\n"
1425-
"HDFStore(path, **kwargs) is the replacement",
1426-
FutureWarning,
1427-
stacklevel=6)
1428-
1429-
return HDFStore(path, **kwargs)
1430-
1431-
14321419
class TableIterator(object):
14331420

14341421
""" define the iteration interface on a table

pandas/tests/api/test_api.py

+2-38
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class TestPDApi(Base):
4949
'TimedeltaIndex', 'Timestamp', 'Interval', 'IntervalIndex']
5050

5151
# these are already deprecated; awaiting removal
52-
deprecated_classes = ['TimeGrouper', 'Expr', 'Term']
52+
deprecated_classes = ['TimeGrouper']
5353

5454
# these should be deprecated in the future
5555
deprecated_classes_in_future = ['Panel']
@@ -89,8 +89,7 @@ class TestPDApi(Base):
8989
deprecated_funcs_in_future = []
9090

9191
# these are already deprecated; awaiting removal
92-
deprecated_funcs = ['pnow', 'match', 'groupby', 'get_store',
93-
'plot_params', 'scatter_matrix']
92+
deprecated_funcs = ['plot_params', 'scatter_matrix']
9493

9594
def test_api(self):
9695

@@ -131,46 +130,11 @@ class TestTopLevelDeprecations(object):
131130
# top-level API deprecations
132131
# GH 13790
133132

134-
def test_pnow(self):
135-
with tm.assert_produces_warning(FutureWarning,
136-
check_stacklevel=False):
137-
pd.pnow(freq='M')
138-
139-
def test_term(self):
140-
with tm.assert_produces_warning(FutureWarning,
141-
check_stacklevel=False):
142-
pd.Term('index>=date')
143-
144-
def test_expr(self):
145-
with tm.assert_produces_warning(FutureWarning,
146-
check_stacklevel=False):
147-
pd.Expr('2>1')
148-
149-
def test_match(self):
150-
with tm.assert_produces_warning(FutureWarning,
151-
check_stacklevel=False):
152-
pd.match([1, 2, 3], [1])
153-
154-
def test_groupby(self):
155-
with tm.assert_produces_warning(FutureWarning,
156-
check_stacklevel=False):
157-
pd.groupby(pd.Series([1, 2, 3]), [1, 1, 1])
158-
159133
def test_TimeGrouper(self):
160134
with tm.assert_produces_warning(FutureWarning,
161135
check_stacklevel=False):
162136
pd.TimeGrouper(freq='D')
163137

164-
# GH 15940
165-
166-
def test_get_store(self):
167-
pytest.importorskip('tables')
168-
with tm.ensure_clean() as path:
169-
with tm.assert_produces_warning(FutureWarning,
170-
check_stacklevel=False):
171-
s = pd.get_store(path)
172-
s.close()
173-
174138

175139
class TestParser(object):
176140

pandas/tests/io/test_pytables.py

+1-27
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
tables = pytest.importorskip('tables')
3333
from pandas.io import pytables as pytables # noqa:E402
3434
from pandas.io.pytables import (TableIterator, # noqa:E402
35-
HDFStore, get_store, Term, read_hdf,
35+
HDFStore, Term, read_hdf,
3636
PossibleDataLossError, ClosedFileError)
3737

3838

@@ -146,32 +146,6 @@ def teardown_method(self, method):
146146
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
147147
class TestHDFStore(Base):
148148

149-
def test_factory_fun(self):
150-
path = create_tempfile(self.path)
151-
try:
152-
with tm.assert_produces_warning(FutureWarning,
153-
check_stacklevel=False):
154-
with get_store(path) as tbl:
155-
raise ValueError('blah')
156-
except ValueError:
157-
pass
158-
finally:
159-
safe_remove(path)
160-
161-
try:
162-
with tm.assert_produces_warning(FutureWarning,
163-
check_stacklevel=False):
164-
with get_store(path) as tbl:
165-
tbl['a'] = tm.makeDataFrame()
166-
167-
with tm.assert_produces_warning(FutureWarning,
168-
check_stacklevel=False):
169-
with get_store(path) as tbl:
170-
assert len(tbl) == 1
171-
assert type(tbl['a']) == DataFrame
172-
finally:
173-
safe_remove(self.path)
174-
175149
def test_context(self):
176150
path = create_tempfile(self.path)
177151
try:

pandas/tests/scalar/period/test_period.py

-7
Original file line numberDiff line numberDiff line change
@@ -843,13 +843,6 @@ def test_properties_secondly(self):
843843
assert Period(freq='Min', year=2012, month=2, day=1, hour=0,
844844
minute=0, second=0).days_in_month == 29
845845

846-
def test_pnow(self):
847-
848-
# deprecation, xref #13790
849-
with tm.assert_produces_warning(FutureWarning,
850-
check_stacklevel=False):
851-
period.pnow('D')
852-
853846
def test_constructor_corner(self):
854847
expected = Period('2007-01', freq='2M')
855848
assert Period(year=2007, month=1, freq='2M') == expected

0 commit comments

Comments
 (0)