From e53fd938c9ada41df05090c0d7bf2bf085975df0 Mon Sep 17 00:00:00 2001 From: jequinon Date: Mon, 16 Jul 2018 10:53:45 -0400 Subject: [PATCH 1/8] CLN: Removed tz_convert and tz_localize, fixed test. GH21781 --- pandas/core/indexes/period.py | 46 +-------------------------- pandas/tests/frame/test_timeseries.py | 5 +-- 2 files changed, 2 insertions(+), 49 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index a8e0c7f1aaa6a..e8060567910c5 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -805,50 +805,6 @@ def __setstate__(self, state): _unpickle_compat = __setstate__ - def tz_convert(self, tz): - """ - Convert tz-aware DatetimeIndex from one time zone to another (using - pytz/dateutil) - - Parameters - ---------- - tz : string, pytz.timezone, dateutil.tz.tzfile or None - Time zone for time. Corresponding timestamps would be converted to - time zone of the TimeSeries. - None will remove timezone holding UTC time. - - Returns - ------- - normalized : DatetimeIndex - - Notes - ----- - Not currently implemented for PeriodIndex - """ - raise NotImplementedError("Not yet implemented for PeriodIndex") - - def tz_localize(self, tz, ambiguous='raise'): - """ - Localize tz-naive DatetimeIndex to given time zone (using - pytz/dateutil), or remove timezone from tz-aware DatetimeIndex - - Parameters - ---------- - tz : string, pytz.timezone, dateutil.tz.tzfile or None - Time zone for time. Corresponding timestamps would be converted to - time zone of the TimeSeries. - None will remove timezone holding local time. - - Returns - ------- - localized : DatetimeIndex - - Notes - ----- - Not currently implemented for PeriodIndex - """ - raise NotImplementedError("Not yet implemented for PeriodIndex") - PeriodIndex._add_comparison_methods() PeriodIndex._add_numeric_methods_disabled() @@ -917,4 +873,4 @@ def period_range(start=None, end=None, periods=None, freq='D', name=None): 'exactly two must be specified') return PeriodIndex(start=start, end=end, periods=periods, - freq=freq, name=name) + freq=freq, name=name) \ No newline at end of file diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index fb9bd74d9876d..28f4a2412dde2 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -779,10 +779,7 @@ def test_tz_convert_and_localize(self, fn): # TODO: l1 should be a PeriodIndex for testing # after GH2106 is addressed - with pytest.raises(NotImplementedError): - period_range('20140701', periods=1).tz_convert('UTC') - with pytest.raises(NotImplementedError): - period_range('20140701', periods=1).tz_localize('UTC') + # l1 = period_range('20140701', periods=5, freq='D') l1 = date_range('20140701', periods=5, freq='D') From 6b2c237d938314c9cd2b522ba6daf5eafde71469 Mon Sep 17 00:00:00 2001 From: jequinon Date: Mon, 16 Jul 2018 11:20:15 -0400 Subject: [PATCH 2/8] Removed tz_convert, tz_localize from class doc. GH21781 --- pandas/core/indexes/period.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index e8060567910c5..50abdfb84b148 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -140,8 +140,6 @@ class PeriodIndex(PeriodArrayMixin, DatelikeOps, DatetimeIndexOpsMixin, asfreq strftime to_timestamp - tz_convert - tz_localize Examples -------- From f5dc5d9933a67ed663fde61102b9ce65387d3975 Mon Sep 17 00:00:00 2001 From: jequinon Date: Mon, 16 Jul 2018 12:25:11 -0400 Subject: [PATCH 3/8] Added changes to whatsnew doc --- doc/source/whatsnew/v0.24.0.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 9e3f7ec73f852..d7c830c6556e2 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -322,7 +322,7 @@ Removal of prior version deprecations/changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - The ``LongPanel`` and ``WidePanel`` classes have been removed (:issue:`10892`) -- +- :meth:`PeriodIndex.tz_convert` and :meth:`PeriodIndex.tz_localize` have been removed (:issue:`21781`) - - From 26c8bc228f876c25998492c9ade03abfebbeef77 Mon Sep 17 00:00:00 2001 From: jequinon Date: Mon, 16 Jul 2018 12:43:23 -0400 Subject: [PATCH 4/8] Added newline to fix style error --- pandas/core/indexes/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 50abdfb84b148..f97f93d975af2 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -871,4 +871,4 @@ def period_range(start=None, end=None, periods=None, freq='D', name=None): 'exactly two must be specified') return PeriodIndex(start=start, end=end, periods=periods, - freq=freq, name=name) \ No newline at end of file + freq=freq, name=name) From 2ce60ec18105892ab3daf3c451a557d76a5b03f2 Mon Sep 17 00:00:00 2001 From: jequinon Date: Mon, 16 Jul 2018 14:29:10 -0400 Subject: [PATCH 5/8] Removed double include causing failed build, updated api.rst --- doc/source/api.rst | 2 -- pandas/tests/frame/test_timeseries.py | 1 - 2 files changed, 3 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index fff944651588e..beded99318a5e 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1870,8 +1870,6 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp - PeriodIndex.tz_convert - PeriodIndex.tz_localize Scalars ------- diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index 28f4a2412dde2..22ce08e55cd63 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -747,7 +747,6 @@ def test_datetime_assignment_with_NaT_and_diff_time_units(self): def test_frame_to_period(self): K = 5 - from pandas.core.indexes.period import period_range dr = date_range('1/1/2000', '1/1/2001') pr = period_range('1/1/2000', '1/1/2001') From 24a166a0b0932bdabc715f506d5d59b9bce38d4c Mon Sep 17 00:00:00 2001 From: jequinon Date: Mon, 16 Jul 2018 15:15:02 -0400 Subject: [PATCH 6/8] Removing previous api.rst changes, caused unexpected failures --- doc/source/api.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/api.rst b/doc/source/api.rst index beded99318a5e..fff944651588e 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1870,6 +1870,8 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp + PeriodIndex.tz_convert + PeriodIndex.tz_localize Scalars ------- From 3867931825f860a60165327f5b4110e993497c1d Mon Sep 17 00:00:00 2001 From: jequinon Date: Tue, 17 Jul 2018 14:29:22 -0400 Subject: [PATCH 7/8] Moved whatsnew entry to Other API Changes, and removed unecessary comments --- doc/source/whatsnew/v0.24.0.txt | 4 ++-- pandas/tests/frame/test_timeseries.py | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index d7c830c6556e2..c7c24a284fea7 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -304,7 +304,7 @@ Other API Changes a ``KeyError`` (:issue:`21678`). - Invalid construction of ``IntervalDtype`` will now always raise a ``TypeError`` rather than a ``ValueError`` if the subdtype is invalid (:issue:`21185`) - Trying to reindex a ``DataFrame`` with a non unique ``MultiIndex`` now raises a ``ValueError`` instead of an ``Exception`` (:issue:`21770`) -- +- :meth:`PeriodIndex.tz_convert` and :meth:`PeriodIndex.tz_localize` have been removed (:issue:`21781`) .. _whatsnew_0240.deprecations: @@ -322,7 +322,7 @@ Removal of prior version deprecations/changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - The ``LongPanel`` and ``WidePanel`` classes have been removed (:issue:`10892`) -- :meth:`PeriodIndex.tz_convert` and :meth:`PeriodIndex.tz_localize` have been removed (:issue:`21781`) +- - - diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index 22ce08e55cd63..b1d9d362d1402 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -775,11 +775,6 @@ def test_frame_to_period(self): @pytest.mark.parametrize("fn", ['tz_localize', 'tz_convert']) def test_tz_convert_and_localize(self, fn): l0 = date_range('20140701', periods=5, freq='D') - - # TODO: l1 should be a PeriodIndex for testing - # after GH2106 is addressed - - # l1 = period_range('20140701', periods=5, freq='D') l1 = date_range('20140701', periods=5, freq='D') int_idx = Index(range(5)) From f46f84878f203b9889ac4eba878def2c841dc713 Mon Sep 17 00:00:00 2001 From: jequinon Date: Tue, 17 Jul 2018 16:49:39 -0400 Subject: [PATCH 8/8] Removed methods from api.rst again --- doc/source/api.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index fff944651588e..beded99318a5e 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1870,8 +1870,6 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp - PeriodIndex.tz_convert - PeriodIndex.tz_localize Scalars -------