Skip to content

Commit

Permalink
CLN: Remove tseries v0.19.0 deprecations (#19023)
Browse files Browse the repository at this point in the history
* Remove frequencies.get_standard_freq
* Drop the "freqstr" keyword from frequencies.to_offset

Deprecated in v0.19.0

xref gh-13874
  • Loading branch information
gfyoung authored and jreback committed Jan 2, 2018
1 parent c19bdc9 commit a697421
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 49 deletions.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ Removal of prior version deprecations/changes
- :func:`read_csv` has dropped the ``compact_ints`` and ``use_unsigned`` parameters (:issue:`13323`)
- The ``Timestamp`` class has dropped the ``offset`` attribute in favor of ``freq`` (:issue:`13593`)
- The ``Series``, ``Categorical``, and ``Index`` classes have dropped the ``reshape`` method (:issue:`13012`)
- ``pandas.tseries.frequencies.get_standard_freq`` has been removed in favor of ``pandas.tseries.frequencies.to_offset(freq).rule_code`` (:issue:`13874`)
- The ``freqstr`` keyword has been removed from ``pandas.tseries.frequencies.to_offset`` in favor of ``freq`` (:issue:`13874`)

.. _whatsnew_0230.performance:

Expand Down
32 changes: 2 additions & 30 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from pandas.compat.numpy import np_datetime64_compat

from pandas.core.series import Series
from pandas.tseries.frequencies import (_offset_map, get_freq_code,
_get_freq_str, _INVALID_FREQ_ERROR,
get_offset, get_standard_freq)
from pandas.tseries.frequencies import (_offset_map, get_freq_code, get_offset,
_get_freq_str, _INVALID_FREQ_ERROR)
from pandas.core.indexes.datetimes import (
_to_m8, DatetimeIndex, _daterange_cache)
import pandas._libs.tslibs.offsets as liboffsets
Expand Down Expand Up @@ -2786,33 +2785,6 @@ def test_get_offset_legacy():
get_offset(name)


def test_get_standard_freq():
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
fstr = get_standard_freq('W')
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert fstr == get_standard_freq('w')
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert fstr == get_standard_freq('1w')
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert fstr == get_standard_freq(('W', 1))

with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
get_standard_freq('WeEk')

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
fstr = get_standard_freq('5Q')
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert fstr == get_standard_freq('5q')

with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
get_standard_freq('5QuarTer')

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert fstr == get_standard_freq(('q', 5))


class TestOffsetAliases(object):

def setup_method(self, method):
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/tseries/test_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,6 @@ def test_frequency_misc(self):
with tm.assert_raises_regex(ValueError, 'Could not evaluate'):
frequencies.to_offset(('', ''))

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
result = frequencies.get_standard_freq(offsets.Hour())
assert result == 'H'


_dti = DatetimeIndex

Expand Down
15 changes: 0 additions & 15 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pandas.compat import zip
from pandas import compat
import re
import warnings

import numpy as np

Expand All @@ -14,7 +13,6 @@
is_datetime64_dtype)

from pandas.tseries.offsets import DateOffset
from pandas.util._decorators import deprecate_kwarg
import pandas.tseries.offsets as offsets

from pandas._libs.tslib import Timedelta
Expand Down Expand Up @@ -143,7 +141,6 @@ def get_period_alias(offset_str):
'nanoseconds': Nano(1)}


@deprecate_kwarg(old_arg_name='freqstr', new_arg_name='freq')
def to_offset(freq):
"""
Return DateOffset object from string or tuple representation
Expand Down Expand Up @@ -294,18 +291,6 @@ def get_offset(name):

getOffset = get_offset


def get_standard_freq(freq):
"""
Return the standardized frequency string
"""

msg = ("get_standard_freq is deprecated. Use to_offset(freq).rule_code "
"instead.")
warnings.warn(msg, FutureWarning, stacklevel=2)
return to_offset(freq).rule_code


# ---------------------------------------------------------------------
# Period codes

Expand Down

0 comments on commit a697421

Please sign in to comment.