Skip to content

Commit 7f2948c

Browse files
HH-MWBWillAyd
authored andcommitted
replace syntax with f-string (#30919)
1 parent 6e9651e commit 7f2948c

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

pandas/core/arrays/period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ def __arrow_array__(self, type=None):
298298
if self.freqstr != type.freq:
299299
raise TypeError(
300300
"Not supported to convert PeriodArray to array with different"
301-
" 'freq' ({0} vs {1})".format(self.freqstr, type.freq)
301+
f" 'freq' ({self.freqstr} vs {type.freq})"
302302
)
303303
else:
304304
raise TypeError(
305-
"Not supported to convert PeriodArray to '{0}' type".format(type)
305+
f"Not supported to convert PeriodArray to '{type}' type"
306306
)
307307

308308
period_type = ArrowPeriodType(self.freqstr)

pandas/core/dtypes/common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,11 @@ def ensure_python_int(value: Union[int, np.integer]) -> int:
194194
"""
195195
if not is_scalar(value):
196196
raise TypeError(f"Value needs to be a scalar value, was type {type(value)}")
197-
msg = "Wrong type {} for value {}"
198197
try:
199198
new_value = int(value)
200199
assert new_value == value
201200
except (TypeError, ValueError, AssertionError):
202-
raise TypeError(msg.format(type(value), value))
201+
raise TypeError(f"Wrong type {type(value)} for value {value}")
203202
return new_value
204203

205204

pandas/core/dtypes/dtypes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,11 @@ def __eq__(self, other: Any) -> bool:
435435
return hash(self) == hash(other)
436436

437437
def __repr__(self) -> str_type:
438-
tpl = "CategoricalDtype(categories={data}ordered={ordered})"
439438
if self.categories is None:
440439
data = "None, "
441440
else:
442441
data = self.categories._format_data(name=type(self).__name__)
443-
return tpl.format(data=data, ordered=self.ordered)
442+
return f"CategoricalDtype(categories={data}ordered={self.ordered})"
444443

445444
@staticmethod
446445
def _hash_categories(categories, ordered: Ordered = True) -> int:

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ def _verbose_repr():
24312431
dtype = self.dtypes.iloc[i]
24322432
col = pprint_thing(col)
24332433

2434-
line_no = _put_str(" {num}".format(num=i), space_num)
2434+
line_no = _put_str(f" {i}", space_num)
24352435
count = ""
24362436
if show_counts:
24372437
count = counts.iloc[i]

0 commit comments

Comments
 (0)