diff --git a/doc/source/whatsnew/v0.19.0.txt b/doc/source/whatsnew/v0.19.0.txt index 62091d7ff03ff..74645b83ea145 100644 --- a/doc/source/whatsnew/v0.19.0.txt +++ b/doc/source/whatsnew/v0.19.0.txt @@ -699,7 +699,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: diff --git a/pandas/src/period.pyx b/pandas/src/period.pyx index 965ed53a4b802..0435b01920504 100644 --- a/pandas/src/period.pyx +++ b/pandas/src/period.pyx @@ -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) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 8b3785d78d260..eaf826230e772 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -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) diff --git a/pandas/tseries/tests/test_period.py b/pandas/tseries/tests/test_period.py index c3d0ee28540e1..290c11bd8d79c 100644 --- a/pandas/tseries/tests/test_period.py +++ b/pandas/tseries/tests/test_period.py @@ -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')),