diff --git a/pandas/core/resample.py b/pandas/core/resample.py index a8a48624fb885..473c6807ec7a5 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -1020,6 +1020,10 @@ def __init__(self, freq='Min', closed=None, label=None, how='mean', nperiods=None, axis=0, fill_method=None, limit=None, loffset=None, kind=None, convention=None, base=0, **kwargs): + # deprecation TimeGrouper, #16747 + warnings.warn("TimeGrouper is deprecated. Please use " + "Grouper", FutureWarning, stacklevel=2) + freq = to_offset(freq) end_types = set(['M', 'A', 'Q', 'BM', 'BA', 'BQ', 'W']) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index b1652cf6eb6db..03acf8ac65cca 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -47,12 +47,13 @@ class TestPDApi(Base): 'Grouper', 'HDFStore', 'Index', 'Int64Index', 'MultiIndex', 'Period', 'PeriodIndex', 'RangeIndex', 'UInt64Index', 'Series', 'SparseArray', 'SparseDataFrame', - 'SparseSeries', 'TimeGrouper', 'Timedelta', + 'SparseSeries', 'Timedelta', 'TimedeltaIndex', 'Timestamp', 'Interval', 'IntervalIndex'] # these are already deprecated; awaiting removal deprecated_classes = ['WidePanel', 'Panel4D', - 'SparseList', 'Expr', 'Term'] + 'SparseList', 'Expr', 'Term', + 'TimeGrouper'] # these should be deprecated in the future deprecated_classes_in_future = ['Panel'] diff --git a/pandas/tests/test_resample.py b/pandas/tests/test_resample.py index 15bbd7a9ef5e9..7a7350a7ed099 100644 --- a/pandas/tests/test_resample.py +++ b/pandas/tests/test_resample.py @@ -3030,6 +3030,11 @@ def setup_method(self, method): self.ts = Series(np.random.randn(1000), index=date_range('1/1/2000', periods=1000)) + def test_TimeGrouper_deprecation(self): + # GH 16747 + with tm.assert_produces_warning(FutureWarning): + TimeGrouper('A', label='right', closed='right') + def test_apply(self): grouper = TimeGrouper('A', label='right', closed='right')