Skip to content

Commit 78d8891

Browse files
authored
CLN: Replace '.format' with f-strings in some test files #29547 (#31412)
1 parent 06f2996 commit 78d8891

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

pandas/tests/reshape/test_reshape.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ def test_basic_types(self, sparse, dtype):
8686

8787
result = get_dummies(s_df, columns=s_df.columns, sparse=sparse, dtype=dtype)
8888
if sparse:
89-
dtype_name = "Sparse[{}, {}]".format(
90-
self.effective_dtype(dtype).name, fill_value
91-
)
89+
dtype_name = f"Sparse[{self.effective_dtype(dtype).name}, {fill_value}]"
9290
else:
9391
dtype_name = self.effective_dtype(dtype).name
9492

@@ -163,8 +161,7 @@ def test_unicode(self, sparse):
163161
s = [e, eacute, eacute]
164162
res = get_dummies(s, prefix="letter", sparse=sparse)
165163
exp = DataFrame(
166-
{"letter_e": [1, 0, 0], "letter_{eacute}".format(eacute=eacute): [0, 1, 1]},
167-
dtype=np.uint8,
164+
{"letter_e": [1, 0, 0], f"letter_{eacute}": [0, 1, 1]}, dtype=np.uint8,
168165
)
169166
if sparse:
170167
exp = exp.apply(SparseArray, fill_value=0)

pandas/tests/scalar/period/test_period.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def test_multiples(self):
308308
@pytest.mark.parametrize("month", MONTHS)
309309
def test_period_cons_quarterly(self, month):
310310
# bugs in scikits.timeseries
311-
freq = "Q-{month}".format(month=month)
311+
freq = f"Q-{month}"
312312
exp = Period("1989Q3", freq=freq)
313313
assert "1989Q3" in str(exp)
314314
stamp = exp.to_timestamp("D", how="end")
@@ -322,7 +322,7 @@ def test_period_cons_quarterly(self, month):
322322
@pytest.mark.parametrize("month", MONTHS)
323323
def test_period_cons_annual(self, month):
324324
# bugs in scikits.timeseries
325-
freq = "A-{month}".format(month=month)
325+
freq = f"A-{month}"
326326
exp = Period("1989", freq=freq)
327327
stamp = exp.to_timestamp("D", how="end") + timedelta(days=30)
328328
p = Period(stamp, freq=freq)
@@ -333,8 +333,8 @@ def test_period_cons_annual(self, month):
333333
@pytest.mark.parametrize("day", DAYS)
334334
@pytest.mark.parametrize("num", range(10, 17))
335335
def test_period_cons_weekly(self, num, day):
336-
daystr = "2011-02-{num}".format(num=num)
337-
freq = "W-{day}".format(day=day)
336+
daystr = f"2011-02-{num}"
337+
freq = f"W-{day}"
338338

339339
result = Period(daystr, freq=freq)
340340
expected = Period(daystr, freq="D").asfreq(freq)

0 commit comments

Comments
 (0)