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/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 9e3f7ec73f852..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: diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index a8e0c7f1aaa6a..f97f93d975af2 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 -------- @@ -805,50 +803,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() diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index fb9bd74d9876d..b1d9d362d1402 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') @@ -776,14 +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 - 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') int_idx = Index(range(5))