Skip to content

CLN: Remove PeriodIndex.tz_convert, tz_localize #21935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 18, 2018
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Copy link
Member

@gfyoung gfyoung Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should go in the Other API Changes section. We generally reserve this area for actual deprecations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, gotcha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I tried to document the changes made in api.rst, but removing the methods caused a bunch of errors in the build. Do you know what is causing that? Do I need to build the docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure ATM. If there's anything to remove in api.rst (or any of the .rst files), it would be reference to the methods that you just removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move to Other API canges, otherwise lgtm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping when this is moved

-
-

Expand Down
46 changes: 0 additions & 46 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class PeriodIndex(PeriodArrayMixin, DatelikeOps, DatetimeIndexOpsMixin,
asfreq
strftime
to_timestamp
tz_convert
tz_localize

Examples
--------
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/frame/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -779,10 +778,7 @@ def test_tz_convert_and_localize(self, fn):

# TODO: l1 should be a PeriodIndex for testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this comment

# 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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment out as well

l1 = date_range('20140701', periods=5, freq='D')

Expand Down