Skip to content

Commit 08c7cae

Browse files
jlamborn324jreback
authored andcommitted
CLN changed .format to f-string for test_converter.py, test_datetimel… (#30248)
1 parent 13b255f commit 08c7cae

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

pandas/tests/plotting/test_converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def _assert_less(ts1, ts2):
268268
val1 = self.dtc.convert(ts1, None, None)
269269
val2 = self.dtc.convert(ts2, None, None)
270270
if not val1 < val2:
271-
raise AssertionError("{0} is not less than {1}.".format(val1, val2))
271+
raise AssertionError(f"{val1} is not less than {val2}.")
272272

273273
# Matplotlib's time representation using floats cannot distinguish
274274
# intervals smaller than ~10 microsecond in the common range of years.

pandas/tests/plotting/test_datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ def test_plot_outofbounds_datetime(self):
13521352

13531353
def test_format_timedelta_ticks_narrow(self):
13541354

1355-
expected_labels = ["00:00:00.0000000{:0>2d}".format(i) for i in np.arange(10)]
1355+
expected_labels = [f"00:00:00.0000000{i:0>2d}" for i in np.arange(10)]
13561356

13571357
rng = timedelta_range("0", periods=10, freq="ns")
13581358
df = DataFrame(np.random.randn(len(rng), 3), rng)

pandas/tests/plotting/test_series.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def test_pie_series(self):
330330
ax = _check_plot_works(
331331
series.plot.pie, colors=color_args, autopct="%.2f", fontsize=7
332332
)
333-
pcts = ["{0:.2f}".format(s * 100) for s in series.values / float(series.sum())]
333+
pcts = [f"{s*100:.2f}" for s in series.values / float(series.sum())]
334334
expected_texts = list(chain.from_iterable(zip(series.index, pcts)))
335335
self._check_text_labels(ax.texts, expected_texts)
336336
for t in ax.texts:
@@ -865,15 +865,15 @@ def test_time_series_plot_color_with_empty_kwargs(self):
865865

866866
def test_xticklabels(self):
867867
# GH11529
868-
s = Series(np.arange(10), index=["P{i:02d}".format(i=i) for i in range(10)])
868+
s = Series(np.arange(10), index=[f"P{i:02d}" for i in range(10)])
869869
_, ax = self.plt.subplots()
870870
ax = s.plot(xticks=[0, 3, 5, 9], ax=ax)
871-
exp = ["P{i:02d}".format(i=i) for i in [0, 3, 5, 9]]
871+
exp = [f"P{i:02d}" for i in [0, 3, 5, 9]]
872872
self._check_text_labels(ax.get_xticklabels(), exp)
873873

874874
def test_xtick_barPlot(self):
875875
# GH28172
876-
s = pd.Series(range(10), index=["P{i:02d}".format(i=i) for i in range(10)])
876+
s = pd.Series(range(10), index=[f"P{i:02d}" for i in range(10)])
877877
ax = s.plot.bar(xticks=range(0, 11, 2))
878878
exp = np.array(list(range(0, 11, 2)))
879879
tm.assert_numpy_array_equal(exp, ax.get_xticks())

0 commit comments

Comments
 (0)