Skip to content

Commit c0cf2c2

Browse files
AncientRicklesWillAyd
authored andcommitted
fixed pandas/io/formats/printing.py formatting: replaced %/{}.format with f strings (#30421)
1 parent 6df408b commit c0cf2c2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pandas/io/formats/printing.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ def format_object_summary(
325325

326326
if indent_for_name:
327327
name_len = len(name)
328-
space1 = "\n%s" % (" " * (name_len + 1))
329-
space2 = "\n%s" % (" " * (name_len + 2))
328+
space1 = f'\n{(" " * (name_len + 1))}'
329+
space2 = f'\n{(" " * (name_len + 2))}'
330330
else:
331331
space1 = "\n"
332332
space2 = "\n " # space for the opening '['
@@ -363,14 +363,14 @@ def best_len(values):
363363
close = ", "
364364

365365
if n == 0:
366-
summary = "[]{}".format(close)
366+
summary = f"[]{close}"
367367
elif n == 1 and not line_break_each_value:
368368
first = formatter(obj[0])
369-
summary = "[{}]{}".format(first, close)
369+
summary = f"[{first}]{close}"
370370
elif n == 2 and not line_break_each_value:
371371
first = formatter(obj[0])
372372
last = formatter(obj[-1])
373-
summary = "[{}, {}]{}".format(first, last, close)
373+
summary = f"[{first}, {last}]{close}"
374374
else:
375375

376376
if n > max_seq_items:
@@ -516,7 +516,7 @@ def format_object_attrs(
516516
attrs: List[Tuple[str, Union[str, int]]] = []
517517
if hasattr(obj, "dtype") and include_dtype:
518518
# error: "Sequence[Any]" has no attribute "dtype"
519-
attrs.append(("dtype", "'{}'".format(obj.dtype))) # type: ignore
519+
attrs.append(("dtype", f"'{obj.dtype}'")) # type: ignore
520520
if getattr(obj, "name", None) is not None:
521521
# error: "Sequence[Any]" has no attribute "name"
522522
attrs.append(("name", default_pprint(obj.name))) # type: ignore

0 commit comments

Comments
 (0)