File tree 3 files changed +15
-1
lines changed
3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -89,3 +89,4 @@ Bug Fixes
89
89
- Bug in GroupBy.get_group raises ValueError when group key contains NaT (:issue:`6992`)
90
90
91
91
92
+ - Bug where infer_freq infers timerule (WOM-5XXX) unsupported by to_offset (:issue:`9425`)
Original file line number Diff line number Diff line change @@ -935,7 +935,9 @@ def _get_wom_rule(self):
935
935
return None
936
936
937
937
week_of_months = unique ((self .index .day - 1 ) // 7 )
938
- if len (week_of_months ) > 1 :
938
+ # Only attempt to infer up to WOM-4. See #9425
939
+ week_of_months = week_of_months [week_of_months < 4 ]
940
+ if len (week_of_months ) == 0 or len (week_of_months ) > 1 :
939
941
return None
940
942
941
943
# get which week
Original file line number Diff line number Diff line change @@ -211,6 +211,17 @@ def test_week_of_month(self):
211
211
for day in days :
212
212
for i in range (1 , 5 ):
213
213
self ._check_generated_range ('1/1/2000' , 'WOM-%d%s' % (i , day ))
214
+ self ._check_generated_range ('1/1/2000' , 'WOM-%d%s' % (i , day ))
215
+
216
+ def test_fifth_week_of_month (self ):
217
+ # Only supports freq up to WOM-4. See #9425
218
+ func = lambda : date_range ('2014-01-01' , freq = 'WOM-5MON' )
219
+ self .assertRaises (ValueError , func )
220
+
221
+ def test_fifth_week_of_month_infer (self ):
222
+ # Only attempts to infer up to WOM-4. See #9425
223
+ index = DatetimeIndex (["2014-03-31" , "2014-06-30" , "2015-03-30" ])
224
+ assert frequencies .infer_freq (index ) is None
214
225
215
226
def test_week_of_month_fake (self ):
216
227
#All of these dates are on same day of week and are 4 or 5 weeks apart
You can’t perform that action at this time.
0 commit comments