From 92b2d6b80bba7c16e5c9aaa8a5408e9e825058a5 Mon Sep 17 00:00:00 2001 From: tv3141 Date: Fri, 30 Mar 2018 23:29:43 +0100 Subject: [PATCH 1/7] Add `LastWeekOfMonth` to offset prefix mapping. --- pandas/tseries/offsets.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 2e4be7fbdeebf..26979985038a4 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -2480,6 +2480,7 @@ def generate_range(start=None, end=None, periods=None, Hour, # 'H' Day, # 'D' WeekOfMonth, # 'WOM' - FY5253, - FY5253Quarter, + LastWeekOfMonth, # 'LWOM' + FY5253, # 'RE' + FY5253Quarter, # 'REQ' ]) From 4c58b24fcc882d47c436df57e48c3a4c507afbb2 Mon Sep 17 00:00:00 2001 From: tv3141 Date: Fri, 30 Mar 2018 23:46:01 +0100 Subject: [PATCH 2/7] Add Easter prefix. `Easter` was the only offset class without prefix, --- pandas/tseries/offsets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 26979985038a4..38fd79656499e 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -2164,6 +2164,7 @@ class Easter(DateOffset): the revised method which is valid in years 1583-4099. """ + _prefix = 'EASTER' _adjust_dst = True _attributes = frozenset(['n', 'normalize']) @@ -2483,4 +2484,5 @@ def generate_range(start=None, end=None, periods=None, LastWeekOfMonth, # 'LWOM' FY5253, # 'RE' FY5253Quarter, # 'REQ' + Easter, # 'EASTER' ]) From a34c8d7d9a811fc9e3604a61b33c8acb31f57c43 Mon Sep 17 00:00:00 2001 From: tv3141 Date: Fri, 30 Mar 2018 23:52:32 +0100 Subject: [PATCH 3/7] Maintain alphabetic prefix order. --- pandas/tseries/offsets.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 38fd79656499e..1ccb2653b7dc3 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -2452,23 +2452,30 @@ def generate_range(start=None, end=None, periods=None, prefix_mapping = dict((offset._prefix, offset) for offset in [ - YearBegin, # 'AS' YearEnd, # 'A' - BYearBegin, # 'BAS' - BYearEnd, # 'BA' + YearBegin, # 'AS' BusinessDay, # 'B' + BYearEnd, # 'BA' + BYearBegin, # 'BAS' + BusinessHour, # 'BH' BusinessMonthBegin, # 'BMS' BusinessMonthEnd, # 'BM' BQuarterEnd, # 'BQ' BQuarterBegin, # 'BQS' - BusinessHour, # 'BH' CustomBusinessDay, # 'C' + CustomBusinessHour, # 'CBH' CustomBusinessMonthEnd, # 'CBM' CustomBusinessMonthBegin, # 'CBMS' - CustomBusinessHour, # 'CBH' + Day, # 'D' + Easter, # 'EASTER' + Hour, # 'H' + Milli, # 'L' + LastWeekOfMonth, # 'LWOM' MonthEnd, # 'M' MonthBegin, # 'MS' Nano, # 'N' + FY5253, # 'RE' + FY5253Quarter, # 'REQ' SemiMonthEnd, # 'SM' SemiMonthBegin, # 'SMS' Week, # 'W' @@ -2477,12 +2484,5 @@ def generate_range(start=None, end=None, periods=None, Micro, # 'U' QuarterEnd, # 'Q' QuarterBegin, # 'QS' - Milli, # 'L' - Hour, # 'H' - Day, # 'D' WeekOfMonth, # 'WOM' - LastWeekOfMonth, # 'LWOM' - FY5253, # 'RE' - FY5253Quarter, # 'REQ' - Easter, # 'EASTER' ]) From 2fc536ae89fe53b04613a05dfdd691e1dc206ca4 Mon Sep 17 00:00:00 2001 From: tv3141 Date: Sat, 31 Mar 2018 00:40:28 +0100 Subject: [PATCH 4/7] start documenting WOM and LWOM --- doc/source/timeseries.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 466c48b780861..58d3cb1091f97 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -1155,6 +1155,8 @@ frequencies. We will refer to these aliases as *offset aliases*. "L, ms", "milliseconds" "U, us", "microseconds" "N", "nanoseconds" + "WOM, "x-th day of the y-th week of each month frequency" + "LWOM", "x-th day of the last week of each month frequency" Combining Aliases ~~~~~~~~~~~~~~~~~ From 772eda0d098ba8fdb5f8f04e2892c4e9dbba936d Mon Sep 17 00:00:00 2001 From: tv3141 Date: Mon, 2 Apr 2018 13:00:42 +0100 Subject: [PATCH 5/7] Remove Easter from offset prefix mapping. --- pandas/tseries/offsets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 1ccb2653b7dc3..2413af2e1bed9 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -2467,7 +2467,6 @@ def generate_range(start=None, end=None, periods=None, CustomBusinessMonthEnd, # 'CBM' CustomBusinessMonthBegin, # 'CBMS' Day, # 'D' - Easter, # 'EASTER' Hour, # 'H' Milli, # 'L' LastWeekOfMonth, # 'LWOM' From f43211bdbbd9f8028a85b7f9567af87186750fd2 Mon Sep 17 00:00:00 2001 From: tv3141 Date: Mon, 2 Apr 2018 13:03:01 +0100 Subject: [PATCH 6/7] pep8: Remove trailing whitespace --- pandas/tseries/offsets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 2413af2e1bed9..88245bca4b428 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -2453,7 +2453,7 @@ def generate_range(start=None, end=None, periods=None, prefix_mapping = dict((offset._prefix, offset) for offset in [ YearEnd, # 'A' - YearBegin, # 'AS' + YearBegin, # 'AS' BusinessDay, # 'B' BYearEnd, # 'BA' BYearBegin, # 'BAS' From 5c7ab4ba2ce00761233d78da6aff40fdc085e462 Mon Sep 17 00:00:00 2001 From: tv3141 Date: Mon, 2 Apr 2018 13:06:51 +0100 Subject: [PATCH 7/7] Remove prefix from Easter class. --- pandas/tseries/offsets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 88245bca4b428..7758d48009436 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -2164,7 +2164,6 @@ class Easter(DateOffset): the revised method which is valid in years 1583-4099. """ - _prefix = 'EASTER' _adjust_dst = True _attributes = frozenset(['n', 'normalize'])