Skip to content

Commit 5f5927f

Browse files
author
austinc
committed
ENH: Don't infer WOM-5MON if we don't support it (pandas-dev#9425)
1 parent 671b384 commit 5f5927f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pandas/tseries/frequencies.py

+1
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ def _get_wom_rule(self):
926926
return None
927927

928928
week_of_months = unique((self.index.day - 1) // 7)
929+
week_of_months = week_of_months[week_of_months < 4]
929930
if len(week_of_months) > 1:
930931
return None
931932

pandas/tseries/tests/test_frequencies.py

+9
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ def test_week_of_month(self):
210210
for day in days:
211211
for i in range(1, 5):
212212
self._check_generated_range('1/1/2000', 'WOM-%d%s' % (i, day))
213+
self._check_generated_range('1/1/2000', 'WOM-%d%s' % (i, day))
214+
215+
def test_fifth_week_of_month(self):
216+
func = lambda: date_range('2014-01-01', freq='WOM-5MON')
217+
self.assertRaises(ValueError, func)
218+
219+
def test_fifth_week_of_month_infer(self):
220+
index = DatetimeIndex(["2014-03-31", "2014-06-30", "2015-03-30"])
221+
assert frequencies.infer_freq(index) is None
213222

214223
def test_week_of_month_fake(self):
215224
#All of these dates are on same day of week and are 4 or 5 weeks apart

0 commit comments

Comments
 (0)