@@ -256,7 +256,7 @@ def to_string(self) -> str:
256
256
257
257
fmt_values = [i .strip () for i in fmt_values ]
258
258
values = ", " .join (fmt_values )
259
- result = ["[" + values + " ]" ]
259
+ result = [f"[ { values } ]" ]
260
260
if self .footer :
261
261
footer = self ._get_footer ()
262
262
if footer :
@@ -417,10 +417,10 @@ def to_string(self) -> str:
417
417
result = self .adj .adjoin (3 , fmt_values )
418
418
419
419
if self .header and have_header :
420
- result = fmt_index [0 ] + " \n " + result
420
+ result = f" { fmt_index [0 ]} \n { result } "
421
421
422
422
if footer :
423
- result += "\n " + footer
423
+ result += f "\n { footer } "
424
424
425
425
return str ("" .join (result ))
426
426
@@ -936,7 +936,7 @@ def space_format(x, y):
936
936
and need_leadsp [x ]
937
937
and not restrict_formatting
938
938
):
939
- return " " + y
939
+ return f" { y } "
940
940
return y
941
941
942
942
str_columns = list (
@@ -951,7 +951,7 @@ def space_format(x, y):
951
951
dtypes = self .frame .dtypes
952
952
need_leadsp = dict (zip (fmt_columns , map (is_numeric_dtype , dtypes )))
953
953
str_columns = [
954
- [" " + x if not self ._get_formatter (i ) and need_leadsp [x ] else x ]
954
+ [f" { x } " if not self ._get_formatter (i ) and need_leadsp [x ] else x ]
955
955
for i , x in enumerate (fmt_columns )
956
956
]
957
957
# self.str_columns = str_columns
@@ -1534,7 +1534,7 @@ def format_values_with(float_format):
1534
1534
# default formatter leaves a space to the left when formatting
1535
1535
# floats, must be consistent for left-justifying NaNs (GH #25061)
1536
1536
if self .justify == "left" :
1537
- na_rep = " " + self .na_rep
1537
+ na_rep = f" { self .na_rep } "
1538
1538
else :
1539
1539
na_rep = self .na_rep
1540
1540
@@ -1726,7 +1726,7 @@ def format_percentiles(
1726
1726
1727
1727
if np .all (int_idx ):
1728
1728
out = percentiles_round_type .astype (str )
1729
- return [i + " %" for i in out ]
1729
+ return [f" { i } %" for i in out ]
1730
1730
1731
1731
unique_pcts = np .unique (percentiles )
1732
1732
to_begin = unique_pcts [0 ] if unique_pcts [0 ] > 0 else None
@@ -1741,7 +1741,7 @@ def format_percentiles(
1741
1741
out [int_idx ] = percentiles [int_idx ].round ().astype (int ).astype (str )
1742
1742
1743
1743
out [~ int_idx ] = percentiles [~ int_idx ].round (prec ).astype (str )
1744
- return [i + " %" for i in out ]
1744
+ return [f" { i } %" for i in out ]
1745
1745
1746
1746
1747
1747
def is_dates_only (values : np .ndarray | DatetimeArray | Index | DatetimeIndex ) -> bool :
@@ -1929,7 +1929,7 @@ def _make_fixed_width(
1929
1929
def just (x : str ) -> str :
1930
1930
if conf_max is not None :
1931
1931
if (conf_max > 3 ) & (adjustment .len (x ) > max_len ):
1932
- x = x [: max_len - 3 ] + " ..."
1932
+ x = f" { x [:max_len - 3 ]} ..."
1933
1933
return x
1934
1934
1935
1935
strings = [just (x ) for x in strings ]
@@ -2004,7 +2004,7 @@ def should_trim(values: np.ndarray | list[str]) -> bool:
2004
2004
2005
2005
# leave one 0 after the decimal points if need be.
2006
2006
result = [
2007
- x + " 0" if is_number_with_decimal (x ) and x .endswith (decimal ) else x
2007
+ f" { x } 0" if is_number_with_decimal (x ) and x .endswith (decimal ) else x
2008
2008
for x in trimmed
2009
2009
]
2010
2010
return result
0 commit comments