@@ -245,7 +245,7 @@ def infer_freq(index, warn: bool = True) -> Optional[str]:
245
245
):
246
246
raise TypeError (
247
247
"cannot infer freq from a non-convertible dtype "
248
- "on a Series of {dtype}" . format ( dtype = index .dtype )
248
+ f "on a Series of { index .dtype } "
249
249
)
250
250
index = values
251
251
@@ -263,8 +263,7 @@ def infer_freq(index, warn: bool = True) -> Optional[str]:
263
263
if isinstance (index , pd .Index ) and not isinstance (index , pd .DatetimeIndex ):
264
264
if isinstance (index , (pd .Int64Index , pd .Float64Index )):
265
265
raise TypeError (
266
- "cannot infer freq from a non-convertible index "
267
- "type {type}" .format (type = type (index ))
266
+ f"cannot infer freq from a non-convertible index type { type (index )} "
268
267
)
269
268
index = index .values
270
269
@@ -396,15 +395,15 @@ def _infer_daily_rule(self) -> Optional[str]:
396
395
if annual_rule :
397
396
nyears = self .ydiffs [0 ]
398
397
month = MONTH_ALIASES [self .rep_stamp .month ]
399
- alias = "{prefix }-{month}". format ( prefix = annual_rule , month = month )
398
+ alias = f" { annual_rule } -{ month } "
400
399
return _maybe_add_count (alias , nyears )
401
400
402
401
quarterly_rule = self ._get_quarterly_rule ()
403
402
if quarterly_rule :
404
403
nquarters = self .mdiffs [0 ] / 3
405
404
mod_dict = {0 : 12 , 2 : 11 , 1 : 10 }
406
405
month = MONTH_ALIASES [mod_dict [self .rep_stamp .month % 3 ]]
407
- alias = "{prefix }-{month}". format ( prefix = quarterly_rule , month = month )
406
+ alias = f" { quarterly_rule } -{ month } "
408
407
return _maybe_add_count (alias , nquarters )
409
408
410
409
monthly_rule = self ._get_monthly_rule ()
@@ -416,7 +415,7 @@ def _infer_daily_rule(self) -> Optional[str]:
416
415
if days % 7 == 0 :
417
416
# Weekly
418
417
day = int_to_weekday [self .rep_stamp .weekday ()]
419
- return _maybe_add_count ("W-{day}" . format ( day = day ) , days / 7 )
418
+ return _maybe_add_count (f "W-{ day } " , days / 7 )
420
419
else :
421
420
return _maybe_add_count ("D" , days )
422
421
@@ -490,7 +489,7 @@ def _get_wom_rule(self) -> Optional[str]:
490
489
week = week_of_months [0 ] + 1
491
490
wd = int_to_weekday [weekdays [0 ]]
492
491
493
- return "WOM-{week}{weekday}" . format ( week = week , weekday = wd )
492
+ return f "WOM-{ week } { wd } "
494
493
495
494
496
495
class _TimedeltaFrequencyInferer (_FrequencyInferer ):
@@ -500,7 +499,7 @@ def _infer_daily_rule(self):
500
499
if days % 7 == 0 :
501
500
# Weekly
502
501
wd = int_to_weekday [self .rep_stamp .weekday ()]
503
- alias = "W-{weekday}" . format ( weekday = wd )
502
+ alias = f "W-{ wd } "
504
503
return _maybe_add_count (alias , days / 7 )
505
504
else :
506
505
return _maybe_add_count ("D" , days )
@@ -514,6 +513,6 @@ def _maybe_add_count(base: str, count: float) -> str:
514
513
if count != 1 :
515
514
assert count == int (count )
516
515
count = int (count )
517
- return "{count}{base}" . format ( count = count , base = base )
516
+ return f "{ count } { base } "
518
517
else :
519
518
return base
0 commit comments