Skip to content
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

CLN: remove deprecated infer_dst keyword #20490

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions asv_bench/benchmarks/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def setup(self):
freq='S'))

def time_infer_dst(self):
with warnings.catch_warnings(record=True):
self.index.tz_localize('US/Eastern', infer_dst=True)
self.index.tz_localize('US/Eastern', ambiguous='infer')


class ResetIndex(object):
Expand Down
7 changes: 3 additions & 4 deletions doc/source/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2191,10 +2191,9 @@ Ambiguous Times when Localizing

In some cases, localize cannot determine the DST and non-DST hours when there are
duplicates. This often happens when reading files or database records that simply
duplicate the hours. Passing ``ambiguous='infer'`` (``infer_dst`` argument in prior
releases) into ``tz_localize`` will attempt to determine the right offset. Below
the top example will fail as it contains ambiguous times and the bottom will
infer the right offset.
duplicate the hours. Passing ``ambiguous='infer'`` into ``tz_localize`` will
attempt to determine the right offset. Below the top example will fail as it
contains ambiguous times and the bottom will infer the right offset.

.. ipython:: python
Expand Down
4 changes: 4 additions & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,10 @@ Removal of prior version deprecations/changes
- The top-level functions ``pd.rolling_*``, ``pd.expanding_*`` and ``pd.ewm*`` have been removed (Deprecated since v0.18).
Instead, use the DataFrame/Series methods :attr:`~DataFrame.rolling`, :attr:`~DataFrame.expanding` and :attr:`~DataFrame.ewm` (:issue:`18723`)
- Imports from ``pandas.core.common`` for functions such as ``is_datetime64_dtype`` are now removed. These are located in ``pandas.api.types``. (:issue:`13634`, :issue:`19769`)
- The ``infer_dst`` keyword in :meth:`Series.tz_localize`, :meth:`DatetimeIndex.tz_localize`
and :class:`DatetimeIndex` have been removed. ``infer_dst=True`` is equivalent to
``ambiguous='infer'``, and ``infer_dst=False`` to ``ambiguous='raise'`` (:issue:`7963`).


.. _whatsnew_0230.performance:

Expand Down
6 changes: 0 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7937,9 +7937,6 @@ def _tz_convert(ax, tz):
result.set_axis(ax, axis=axis, inplace=True)
return result.__finalize__(self)

@deprecate_kwarg(old_arg_name='infer_dst', new_arg_name='ambiguous',
mapping={True: 'infer',
False: 'raise'})
def tz_localize(self, tz, axis=0, level=None, copy=True,
ambiguous='raise'):
"""
Expand All @@ -7963,9 +7960,6 @@ def tz_localize(self, tz, axis=0, level=None, copy=True,
- 'NaT' will return NaT where there are ambiguous times
- 'raise' will raise an AmbiguousTimeError if there are ambiguous
times
infer_dst : boolean, default False
.. deprecated:: 0.15.0
Attempt to infer fall dst-transition hours based on order

Returns
-------
Expand Down
11 changes: 0 additions & 11 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin,
times)
- 'NaT' will return NaT where there are ambiguous times
- 'raise' will raise an AmbiguousTimeError if there are ambiguous times
infer_dst : boolean, default False
.. deprecated:: 0.15.0
Attempt to infer fall dst-transition hours based on order
name : object
Name to be stored in the index
dayfirst : bool, default False
Expand Down Expand Up @@ -329,8 +326,6 @@ def _add_comparison_methods(cls):
_is_numeric_dtype = False
_infer_as_myclass = True

@deprecate_kwarg(old_arg_name='infer_dst', new_arg_name='ambiguous',
mapping={True: 'infer', False: 'raise'})
def __new__(cls, data=None,
freq=None, start=None, end=None, periods=None, tz=None,
normalize=False, closed=None, ambiguous='raise',
Expand Down Expand Up @@ -2270,8 +2265,6 @@ def tz_convert(self, tz):
# No conversion since timestamps are all UTC to begin with
return self._shallow_copy(tz=tz)

@deprecate_kwarg(old_arg_name='infer_dst', new_arg_name='ambiguous',
mapping={True: 'infer', False: 'raise'})
def tz_localize(self, tz, ambiguous='raise', errors='raise'):
"""
Localize tz-naive DatetimeIndex to tz-aware DatetimeIndex.
Expand Down Expand Up @@ -2306,10 +2299,6 @@ def tz_localize(self, tz, ambiguous='raise', errors='raise'):

.. versionadded:: 0.19.0

infer_dst : boolean, default False
.. deprecated:: 0.15.0
Attempt to infer fall dst-transition hours based on order

Returns
-------
DatetimeIndex
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ def tz_convert(self, tz):
"""
raise NotImplementedError("Not yet implemented for PeriodIndex")

def tz_localize(self, tz, infer_dst=False):
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
Expand All @@ -1106,8 +1106,6 @@ def tz_localize(self, tz, infer_dst=False):
Time zone for time. Corresponding timestamps would be converted to
time zone of the TimeSeries.
None will remove timezone holding local time.
infer_dst : boolean, default False
Attempt to infer fall dst-transition hours based on order
Returns
-------
Expand Down
8 changes: 1 addition & 7 deletions pandas/tests/indexes/datetimes/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ def test_dti_tz_localize_ambiguous_infer(self, tz):
di = DatetimeIndex(times)
localized = di.tz_localize(tz, ambiguous='infer')
tm.assert_index_equal(dr, localized)
with tm.assert_produces_warning(FutureWarning):
localized_old = di.tz_localize(tz, infer_dst=True)
tm.assert_index_equal(dr, localized_old)
tm.assert_index_equal(dr, DatetimeIndex(times, tz=tz,
ambiguous='infer'))

Expand All @@ -353,9 +350,6 @@ def test_dti_tz_localize_ambiguous_infer(self, tz):
localized = dr.tz_localize(tz)
localized_infer = dr.tz_localize(tz, ambiguous='infer')
tm.assert_index_equal(localized, localized_infer)
with tm.assert_produces_warning(FutureWarning):
localized_infer_old = dr.tz_localize(tz, infer_dst=True)
tm.assert_index_equal(localized, localized_infer_old)

@pytest.mark.parametrize('tz', [pytz.timezone('US/Eastern'),
gettz('US/Eastern')])
Expand Down Expand Up @@ -525,7 +519,7 @@ def test_dti_tz_localize_ambiguous_flags(self, tz):
localized = DatetimeIndex(times, tz=tz, ambiguous=is_dst)
tm.assert_index_equal(dr, localized)

# Test duplicate times where infer_dst fails
# Test duplicate times where inferring the dst fails
times += times
di = DatetimeIndex(times)

Expand Down