@@ -409,16 +409,17 @@ def _get_freq_str(base, mult=1):
409409need_suffix = ['QS' , 'BQ' , 'BQS' , 'YS' , 'AS' , 'BY' , 'BA' , 'BYS' , 'BAS' ]
410410for __prefix in need_suffix :
411411 for _m in tslib ._MONTHS :
412- _offset_to_period_map [ '%s-%s' % ( __prefix , _m )] = \
413- _offset_to_period_map [__prefix ]
412+ _alias = '{prefix}-{month}' . format ( prefix = __prefix , month = _m )
413+ _offset_to_period_map [ _alias ] = _offset_to_period_map [__prefix ]
414414for __prefix in ['A' , 'Q' ]:
415415 for _m in tslib ._MONTHS :
416- _alias = '%s-%s' % ( __prefix , _m )
416+ _alias = '{prefix}-{month}' . format ( prefix = __prefix , month = _m )
417417 _offset_to_period_map [_alias ] = _alias
418418
419419_days = ['MON' , 'TUE' , 'WED' , 'THU' , 'FRI' , 'SAT' , 'SUN' ]
420420for _d in _days :
421- _offset_to_period_map ['W-%s' % _d ] = 'W-%s' % _d
421+ _alias = 'W-{day}' .format (day = _d )
422+ _offset_to_period_map [_alias ] = _alias
422423
423424
424425def get_period_alias (offset_str ):
@@ -587,7 +588,7 @@ def _base_and_stride(freqstr):
587588 groups = opattern .match (freqstr )
588589
589590 if not groups :
590- raise ValueError ("Could not evaluate %s" % freqstr )
591+ raise ValueError ("Could not evaluate {freq}" . format ( freq = freqstr ) )
591592
592593 stride = groups .group (1 )
593594
@@ -775,8 +776,8 @@ def infer_freq(index, warn=True):
775776 if not (is_datetime64_dtype (values ) or
776777 is_timedelta64_dtype (values ) or
777778 values .dtype == object ):
778- raise TypeError ("cannot infer freq from a non-convertible "
779- "dtype on a Series of {0 }" .format (index .dtype ))
779+ raise TypeError ("cannot infer freq from a non-convertible dtype "
780+ "on a Series of {dtype }" .format (dtype = index .dtype ))
780781 index = values
781782
782783 if is_period_arraylike (index ):
@@ -789,7 +790,7 @@ def infer_freq(index, warn=True):
789790 if isinstance (index , pd .Index ) and not isinstance (index , pd .DatetimeIndex ):
790791 if isinstance (index , (pd .Int64Index , pd .Float64Index )):
791792 raise TypeError ("cannot infer freq from a non-convertible index "
792- "type {0 }" .format (type (index )))
793+ "type {type }" .format (type = type (index )))
793794 index = index .values
794795
795796 if not isinstance (index , pd .DatetimeIndex ):
@@ -956,15 +957,17 @@ def _infer_daily_rule(self):
956957 if annual_rule :
957958 nyears = self .ydiffs [0 ]
958959 month = _month_aliases [self .rep_stamp .month ]
959- return _maybe_add_count ('%s-%s' % (annual_rule , month ), nyears )
960+ alias = '{prefix}-{month}' .format (prefix = annual_rule , month = month )
961+ return _maybe_add_count (alias , nyears )
960962
961963 quarterly_rule = self ._get_quarterly_rule ()
962964 if quarterly_rule :
963965 nquarters = self .mdiffs [0 ] / 3
964966 mod_dict = {0 : 12 , 2 : 11 , 1 : 10 }
965967 month = _month_aliases [mod_dict [self .rep_stamp .month % 3 ]]
966- return _maybe_add_count ('%s-%s' % (quarterly_rule , month ),
967- nquarters )
968+ alias = '{prefix}-{month}' .format (prefix = quarterly_rule ,
969+ month = month )
970+ return _maybe_add_count (alias , nquarters )
968971
969972 monthly_rule = self ._get_monthly_rule ()
970973 if monthly_rule :
@@ -974,8 +977,8 @@ def _infer_daily_rule(self):
974977 days = self .deltas [0 ] / _ONE_DAY
975978 if days % 7 == 0 :
976979 # Weekly
977- alias = _weekday_rule_aliases [self .rep_stamp .weekday ()]
978- return _maybe_add_count ('W-%s' % alias , days / 7 )
980+ day = _weekday_rule_aliases [self .rep_stamp .weekday ()]
981+ return _maybe_add_count ('W-{day}' . format ( day = day ) , days / 7 )
979982 else :
980983 return _maybe_add_count ('D' , days )
981984
@@ -1048,7 +1051,7 @@ def _get_wom_rule(self):
10481051 week = week_of_months [0 ] + 1
10491052 wd = _weekday_rule_aliases [weekdays [0 ]]
10501053
1051- return 'WOM-%d%s' % (week , wd )
1054+ return 'WOM-{week}{weekday}' . format (week = week , weekday = wd )
10521055
10531056
10541057class _TimedeltaFrequencyInferer (_FrequencyInferer ):
@@ -1058,15 +1061,16 @@ def _infer_daily_rule(self):
10581061 days = self .deltas [0 ] / _ONE_DAY
10591062 if days % 7 == 0 :
10601063 # Weekly
1061- alias = _weekday_rule_aliases [self .rep_stamp .weekday ()]
1062- return _maybe_add_count ('W-%s' % alias , days / 7 )
1064+ wd = _weekday_rule_aliases [self .rep_stamp .weekday ()]
1065+ alias = 'W-{weekday}' .format (weekday = wd )
1066+ return _maybe_add_count (alias , days / 7 )
10631067 else :
10641068 return _maybe_add_count ('D' , days )
10651069
10661070
10671071def _maybe_add_count (base , count ):
10681072 if count != 1 :
1069- return '%d%s' % (count , base )
1073+ return '{count}{base}' . format (count = int ( count ), base = base )
10701074 else :
10711075 return base
10721076
0 commit comments