Skip to content

Commit

Permalink
DEPR: Remove legacy offsets
Browse files Browse the repository at this point in the history
Follow-up to #13590.
Remove legacy offset aliases that remained in
`pandas/tseries/frequencies.py`: `_period_alias_dictionary()` and
`_period_alias_dict`.

Author: agraboso <agraboso@gmail.com>

Closes #13868 from agraboso/follow-13590 and squashes the following commits:

25d932d [agraboso] DEPR: Remove legacy offsets
  • Loading branch information
agraboso authored and jreback committed Aug 2, 2016
1 parent 299fb75 commit 1f55e91
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 115 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ Removal of prior version deprecations/changes
- ``Series.to_csv`` has dropped the ``nanRep`` parameter in favor of ``na_rep`` (:issue:`13804`)
- ``Series.xs``, ``DataFrame.xs``, ``Panel.xs``, ``Panel.major_xs``, and ``Panel.minor_xs`` have dropped the ``copy`` parameter (:issue:`13781`)
- ``str.split`` has dropped the ``return_type`` parameter in favor of ``expand`` (:issue:`13701`)
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`)
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`, :issue:`13868`)

Previous Behavior:

Expand Down
5 changes: 1 addition & 4 deletions pandas/src/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,7 @@ cdef class _Period(object):
@classmethod
def _maybe_convert_freq(cls, object freq):

if isinstance(freq, compat.string_types):
freq = freq.upper()
freq = frequencies._period_alias_dict.get(freq, freq)
elif isinstance(freq, (int, tuple)):
if isinstance(freq, (int, tuple)):
code, stride = frequencies.get_freq_code(freq)
freq = frequencies._get_freq_str(code, stride)

Expand Down
107 changes: 0 additions & 107 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,113 +620,6 @@ def get_standard_freq(freq):
})


def _period_alias_dictionary():
"""
Build freq alias dictionary to support freqs from original c_dates.c file
of the scikits.timeseries library.
"""
alias_dict = {}

M_aliases = ["M", "MTH", "MONTH", "MONTHLY"]
B_aliases = ["B", "BUS", "BUSINESS", "BUSINESSLY", "WEEKDAY"]
D_aliases = ["D", "DAY", "DLY", "DAILY"]
H_aliases = ["H", "HR", "HOUR", "HRLY", "HOURLY"]
T_aliases = ["T", "MIN", "MINUTE", "MINUTELY"]
S_aliases = ["S", "SEC", "SECOND", "SECONDLY"]
L_aliases = ["L", "ms", "MILLISECOND", "MILLISECONDLY"]
U_aliases = ["U", "US", "MICROSECOND", "MICROSECONDLY"]
N_aliases = ["N", "NS", "NANOSECOND", "NANOSECONDLY"]

for k in M_aliases:
alias_dict[k] = 'M'

for k in B_aliases:
alias_dict[k] = 'B'

for k in D_aliases:
alias_dict[k] = 'D'

for k in H_aliases:
alias_dict[k] = 'H'

for k in T_aliases:
alias_dict[k] = 'T'

for k in S_aliases:
alias_dict[k] = 'S'

for k in L_aliases:
alias_dict[k] = 'L'

for k in U_aliases:
alias_dict[k] = 'U'

for k in N_aliases:
alias_dict[k] = 'N'

A_prefixes = ["A", "Y", "ANN", "ANNUAL", "ANNUALLY", "YR", "YEAR",
"YEARLY"]

Q_prefixes = ["Q", "QTR", "QUARTER", "QUARTERLY", "Q-E",
"QTR-E", "QUARTER-E", "QUARTERLY-E"]

month_names = [
["DEC", "DECEMBER"],
["JAN", "JANUARY"],
["FEB", "FEBRUARY"],
["MAR", "MARCH"],
["APR", "APRIL"],
["MAY", "MAY"],
["JUN", "JUNE"],
["JUL", "JULY"],
["AUG", "AUGUST"],
["SEP", "SEPTEMBER"],
["OCT", "OCTOBER"],
["NOV", "NOVEMBER"]]

seps = ["@", "-"]

for k in A_prefixes:
alias_dict[k] = 'A'
for m_tup in month_names:
for sep in seps:
m1, m2 = m_tup
alias_dict[k + sep + m1] = 'A-' + m1
alias_dict[k + sep + m2] = 'A-' + m1

for k in Q_prefixes:
alias_dict[k] = 'Q'
for m_tup in month_names:
for sep in seps:
m1, m2 = m_tup
alias_dict[k + sep + m1] = 'Q-' + m1
alias_dict[k + sep + m2] = 'Q-' + m1

W_prefixes = ["W", "WK", "WEEK", "WEEKLY"]

day_names = [
["SUN", "SUNDAY"],
["MON", "MONDAY"],
["TUE", "TUESDAY"],
["WED", "WEDNESDAY"],
["THU", "THURSDAY"],
["FRI", "FRIDAY"],
["SAT", "SATURDAY"]]

for k in W_prefixes:
alias_dict[k] = 'W'
for d_tup in day_names:
for sep in ["@", "-"]:
d1, d2 = d_tup
alias_dict[k + sep + d1] = 'W-' + d1
alias_dict[k + sep + d2] = 'W-' + d1

return alias_dict


_period_alias_dict = _period_alias_dictionary()


def _period_str_to_code(freqstr):
freqstr = _lite_rule_alias.get(freqstr, freqstr)

Expand Down
10 changes: 7 additions & 3 deletions pandas/tseries/tests/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,14 @@ def test_period_deprecated_freq(self):
for freq in freqs:
with self.assertRaisesRegexp(ValueError, msg):
Period('2016-03-01 09:00', freq=freq)
with self.assertRaisesRegexp(ValueError, msg):
Period(ordinal=1, freq=freq)

# check supported freq-aliases still works
p = Period('2016-03-01 09:00', freq=exp)
tm.assertIsInstance(p, Period)
# check supported freq-aliases still works
p1 = Period('2016-03-01 09:00', freq=exp)
p2 = Period(ordinal=1, freq=exp)
tm.assertIsInstance(p1, Period)
tm.assertIsInstance(p2, Period)

def test_hash(self):
self.assertEqual(hash(Period('2011-01', freq='M')),
Expand Down

0 comments on commit 1f55e91

Please sign in to comment.