@@ -358,7 +358,7 @@ def get_offset(name):
358
358
else :
359
359
if name in _rule_aliases :
360
360
name = _rule_aliases [name ]
361
-
361
+
362
362
if name not in _offset_map :
363
363
try :
364
364
# generate and cache offset
@@ -625,7 +625,7 @@ def _period_str_to_code(freqstr):
625
625
alias = _period_alias_dict [freqstr ]
626
626
except KeyError :
627
627
raise ValueError ("Unknown freqstr: %s" % freqstr )
628
-
628
+
629
629
return _period_code_map [alias ]
630
630
631
631
@@ -647,6 +647,10 @@ def infer_freq(index, warn=True):
647
647
from pandas .tseries .index import DatetimeIndex
648
648
649
649
if not isinstance (index , DatetimeIndex ):
650
+ from pandas .tseries .period import PeriodIndex
651
+ if isinstance (index , PeriodIndex ):
652
+ raise ValueError ("PeriodIndex given. Check the `freq` attribute "
653
+ "instead of using infer_freq." )
650
654
index = DatetimeIndex (index )
651
655
652
656
inferer = _FrequencyInferer (index , warn = warn )
@@ -850,7 +854,7 @@ def _get_wom_rule(self):
850
854
weekdays = unique (self .index .weekday )
851
855
if len (weekdays ) > 1 :
852
856
return None
853
-
857
+
854
858
week_of_months = unique ((self .index .day - 1 ) // 7 )
855
859
if len (week_of_months ) > 1 :
856
860
return None
0 commit comments