@@ -96,9 +96,7 @@ def test_selection(self, index, freq, kind, kwargs):
96
96
def test_annual_upsample_cases (
97
97
self , targ , conv , meth , month , simple_period_range_series
98
98
):
99
- ts = simple_period_range_series (
100
- "1/1/1990" , "12/31/1991" , freq = "A-{month}" .format (month = month )
101
- )
99
+ ts = simple_period_range_series ("1/1/1990" , "12/31/1991" , freq = f"A-{ month } " )
102
100
103
101
result = getattr (ts .resample (targ , convention = conv ), meth )()
104
102
expected = result .to_timestamp (targ , how = conv )
@@ -130,9 +128,9 @@ def test_not_subperiod(self, simple_period_range_series, rule, expected_error_ms
130
128
# These are incompatible period rules for resampling
131
129
ts = simple_period_range_series ("1/1/1990" , "6/30/1995" , freq = "w-wed" )
132
130
msg = (
133
- "Frequency <Week: weekday=2> cannot be resampled to {}, as they "
134
- " are not sub or super periods"
135
- ). format ( expected_error_msg )
131
+ "Frequency <Week: weekday=2> cannot be resampled to "
132
+ f" { expected_error_msg } , as they are not sub or super periods"
133
+ )
136
134
with pytest .raises (IncompatibleFrequency , match = msg ):
137
135
ts .resample (rule ).mean ()
138
136
@@ -176,7 +174,7 @@ def test_annual_upsample(self, simple_period_range_series):
176
174
def test_quarterly_upsample (
177
175
self , month , target , convention , simple_period_range_series
178
176
):
179
- freq = "Q-{month}" . format ( month = month )
177
+ freq = f "Q-{ month } "
180
178
ts = simple_period_range_series ("1/1/1990" , "12/31/1995" , freq = freq )
181
179
result = ts .resample (target , convention = convention ).ffill ()
182
180
expected = result .to_timestamp (target , how = convention )
@@ -351,7 +349,7 @@ def test_fill_method_and_how_upsample(self):
351
349
@pytest .mark .parametrize ("target" , ["D" , "B" ])
352
350
@pytest .mark .parametrize ("convention" , ["start" , "end" ])
353
351
def test_weekly_upsample (self , day , target , convention , simple_period_range_series ):
354
- freq = "W-{day}" . format ( day = day )
352
+ freq = f "W-{ day } "
355
353
ts = simple_period_range_series ("1/1/1990" , "12/31/1995" , freq = freq )
356
354
result = ts .resample (target , convention = convention ).ffill ()
357
355
expected = result .to_timestamp (target , how = convention )
@@ -367,16 +365,14 @@ def test_resample_to_timestamps(self, simple_period_range_series):
367
365
368
366
def test_resample_to_quarterly (self , simple_period_range_series ):
369
367
for month in MONTHS :
370
- ts = simple_period_range_series (
371
- "1990" , "1992" , freq = "A-{month}" .format (month = month )
372
- )
373
- quar_ts = ts .resample ("Q-{month}" .format (month = month )).ffill ()
368
+ ts = simple_period_range_series ("1990" , "1992" , freq = f"A-{ month } " )
369
+ quar_ts = ts .resample (f"Q-{ month } " ).ffill ()
374
370
375
371
stamps = ts .to_timestamp ("D" , how = "start" )
376
372
qdates = period_range (
377
373
ts .index [0 ].asfreq ("D" , "start" ),
378
374
ts .index [- 1 ].asfreq ("D" , "end" ),
379
- freq = "Q-{month}" . format ( month = month ) ,
375
+ freq = f "Q-{ month } " ,
380
376
)
381
377
382
378
expected = stamps .reindex (qdates .to_timestamp ("D" , "s" ), method = "ffill" )
0 commit comments