Skip to content

Commit a2cc230

Browse files
ENH/BUG: add missing offsets to prefix map
Ties prefix map to `__all__` so future updates are automatic
1 parent d0342aa commit a2cc230

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

pandas/tseries/offsets.py

+3-28
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
'MonthBegin', 'BMonthBegin', 'MonthEnd', 'BMonthEnd',
1717
'YearBegin', 'BYearBegin', 'YearEnd', 'BYearEnd',
1818
'QuarterBegin', 'BQuarterBegin', 'QuarterEnd', 'BQuarterEnd',
19-
'LastWeekOfMonth', 'FY5253Quarter', 'FY5253',
20-
'Week', 'WeekOfMonth',
19+
'FY5253Quarter', 'FY5253',
20+
'Week', 'WeekOfMonth', 'LastWeekOfMonth',
2121
'Hour', 'Minute', 'Second', 'Milli', 'Micro', 'Nano']
2222

2323
# convert to/from datetime/timestamp to allow invalid Timestamp ranges to pass thru
@@ -1848,32 +1848,7 @@ def generate_range(start=None, end=None, periods=None,
18481848
raise ValueError('Offset %s did not increment date' % offset)
18491849
cur = next_date
18501850

1851-
prefix_mapping = dict((offset._prefix, offset) for offset in [
1852-
YearBegin, # 'AS'
1853-
YearEnd, # 'A'
1854-
BYearBegin, # 'BAS'
1855-
BYearEnd, # 'BA'
1856-
BusinessDay, # 'B'
1857-
BusinessMonthBegin, # 'BMS'
1858-
BusinessMonthEnd, # 'BM'
1859-
BQuarterEnd, # 'BQ'
1860-
BQuarterBegin, # 'BQS'
1861-
CustomBusinessDay, # 'C'
1862-
MonthEnd, # 'M'
1863-
MonthBegin, # 'MS'
1864-
Week, # 'W'
1865-
Second, # 'S'
1866-
Minute, # 'T'
1867-
Micro, # 'U'
1868-
QuarterEnd, # 'Q'
1869-
QuarterBegin, # 'QS'
1870-
Milli, # 'L'
1871-
Hour, # 'H'
1872-
Day, # 'D'
1873-
WeekOfMonth, # 'WOM'
1874-
FY5253,
1875-
FY5253Quarter,
1876-
])
1851+
prefix_mapping = dict([(locals()[offset]._prefix, offset) for offset in __all__])
18771852

18781853
if not _np_version_under1p7:
18791854
# Only 1.7+ supports nanosecond resolution

0 commit comments

Comments
 (0)