From 397d5476705fe606738e0a89a147fdb5d9524695 Mon Sep 17 00:00:00 2001 From: stevemontana1980 Date: Sat, 15 Jul 2017 11:58:05 +0200 Subject: [PATCH 1/5] Add deprecation warning to TimeGrouper --- pandas/core/resample.py | 4 ++++ 1 file changed, 4 insertions(+) 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']) From 7d8797b0f231dde60c6ddd0ba6982ce573f8878e Mon Sep 17 00:00:00 2001 From: stevemontana1980 Date: Sat, 15 Jul 2017 12:00:26 +0200 Subject: [PATCH 2/5] Add TimeGrouper to deprecated_classes_in_future --- pandas/tests/api/test_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index b1652cf6eb6db..670adc4c05b95 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -47,7 +47,7 @@ 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 @@ -55,7 +55,7 @@ class TestPDApi(Base): 'SparseList', 'Expr', 'Term'] # these should be deprecated in the future - deprecated_classes_in_future = ['Panel'] + deprecated_classes_in_future = ['Panel', 'TimeGrouper'] # external modules exposed in pandas namespace modules = ['np', 'datetime'] From c82089f01314a71bbaddd3318c34449fa21a2f1c Mon Sep 17 00:00:00 2001 From: stevemontana1980 Date: Sat, 15 Jul 2017 12:01:20 +0200 Subject: [PATCH 3/5] Add test class TimeGrouper_deprecation --- pandas/tests/test_resample.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/tests/test_resample.py b/pandas/tests/test_resample.py index 15bbd7a9ef5e9..0528fc7f292ec 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): + # deprecation TimeGrouper, #16747 + with tm.assert_produces_warning(FutureWarning): + TimeGrouper('A', label='right', closed='right') + def test_apply(self): grouper = TimeGrouper('A', label='right', closed='right') From cc3cec71cee34027cea2c8a146641327bc193c99 Mon Sep 17 00:00:00 2001 From: stevemontana1980 Date: Sat, 15 Jul 2017 14:40:00 +0200 Subject: [PATCH 4/5] Add TimeGrouper to deprecated_classes --- pandas/tests/api/test_api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 670adc4c05b95..03acf8ac65cca 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -52,10 +52,11 @@ class TestPDApi(Base): # 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', 'TimeGrouper'] + deprecated_classes_in_future = ['Panel'] # external modules exposed in pandas namespace modules = ['np', 'datetime'] From 5f044e9c86db584a4aba7f7ac8fadc8074ac5c90 Mon Sep 17 00:00:00 2001 From: stevemontana1980 Date: Sat, 15 Jul 2017 14:40:47 +0200 Subject: [PATCH 5/5] Change ref to github issue --- pandas/tests/test_resample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/test_resample.py b/pandas/tests/test_resample.py index 0528fc7f292ec..7a7350a7ed099 100644 --- a/pandas/tests/test_resample.py +++ b/pandas/tests/test_resample.py @@ -3031,7 +3031,7 @@ def setup_method(self, method): index=date_range('1/1/2000', periods=1000)) def test_TimeGrouper_deprecation(self): - # deprecation TimeGrouper, #16747 + # GH 16747 with tm.assert_produces_warning(FutureWarning): TimeGrouper('A', label='right', closed='right')