@@ -409,16 +409,17 @@ def _get_freq_str(base, mult=1):
409
409
need_suffix = ['QS' , 'BQ' , 'BQS' , 'YS' , 'AS' , 'BY' , 'BA' , 'BYS' , 'BAS' ]
410
410
for __prefix in need_suffix :
411
411
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 ]
414
414
for __prefix in ['A' , 'Q' ]:
415
415
for _m in tslib ._MONTHS :
416
- _alias = '%s-%s' % ( __prefix , _m )
416
+ _alias = '{prefix}-{month}' . format ( prefix = __prefix , month = _m )
417
417
_offset_to_period_map [_alias ] = _alias
418
418
419
419
_days = ['MON' , 'TUE' , 'WED' , 'THU' , 'FRI' , 'SAT' , 'SUN' ]
420
420
for _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
422
423
423
424
424
425
def get_period_alias (offset_str ):
@@ -587,7 +588,7 @@ def _base_and_stride(freqstr):
587
588
groups = opattern .match (freqstr )
588
589
589
590
if not groups :
590
- raise ValueError ("Could not evaluate %s" % freqstr )
591
+ raise ValueError ("Could not evaluate {freq}" . format ( freq = freqstr ) )
591
592
592
593
stride = groups .group (1 )
593
594
@@ -775,8 +776,8 @@ def infer_freq(index, warn=True):
775
776
if not (is_datetime64_dtype (values ) or
776
777
is_timedelta64_dtype (values ) or
777
778
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 ))
780
781
index = values
781
782
782
783
if is_period_arraylike (index ):
@@ -789,7 +790,7 @@ def infer_freq(index, warn=True):
789
790
if isinstance (index , pd .Index ) and not isinstance (index , pd .DatetimeIndex ):
790
791
if isinstance (index , (pd .Int64Index , pd .Float64Index )):
791
792
raise TypeError ("cannot infer freq from a non-convertible index "
792
- "type {0 }" .format (type (index )))
793
+ "type {type }" .format (type = type (index )))
793
794
index = index .values
794
795
795
796
if not isinstance (index , pd .DatetimeIndex ):
@@ -956,15 +957,17 @@ def _infer_daily_rule(self):
956
957
if annual_rule :
957
958
nyears = self .ydiffs [0 ]
958
959
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 )
960
962
961
963
quarterly_rule = self ._get_quarterly_rule ()
962
964
if quarterly_rule :
963
965
nquarters = self .mdiffs [0 ] / 3
964
966
mod_dict = {0 : 12 , 2 : 11 , 1 : 10 }
965
967
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 )
968
971
969
972
monthly_rule = self ._get_monthly_rule ()
970
973
if monthly_rule :
@@ -974,8 +977,8 @@ def _infer_daily_rule(self):
974
977
days = self .deltas [0 ] / _ONE_DAY
975
978
if days % 7 == 0 :
976
979
# 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 )
979
982
else :
980
983
return _maybe_add_count ('D' , days )
981
984
@@ -1048,7 +1051,7 @@ def _get_wom_rule(self):
1048
1051
week = week_of_months [0 ] + 1
1049
1052
wd = _weekday_rule_aliases [weekdays [0 ]]
1050
1053
1051
- return 'WOM-%d%s' % (week , wd )
1054
+ return 'WOM-{week}{weekday}' . format (week = week , weekday = wd )
1052
1055
1053
1056
1054
1057
class _TimedeltaFrequencyInferer (_FrequencyInferer ):
@@ -1058,15 +1061,16 @@ def _infer_daily_rule(self):
1058
1061
days = self .deltas [0 ] / _ONE_DAY
1059
1062
if days % 7 == 0 :
1060
1063
# 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 )
1063
1067
else :
1064
1068
return _maybe_add_count ('D' , days )
1065
1069
1066
1070
1067
1071
def _maybe_add_count (base , count ):
1068
1072
if count != 1 :
1069
- return '%d%s' % (count , base )
1073
+ return '{count}{base}' . format (count = int ( count ), base = base )
1070
1074
else :
1071
1075
return base
1072
1076
0 commit comments