Skip to content

Commit e26c489

Browse files
donehowerWillAyd
authored andcommitted
f strings in core/series (#30025)
1 parent b0ab1c7 commit e26c489

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pandas/core/series.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def _coerce_method(converter):
104104
def wrapper(self):
105105
if len(self) == 1:
106106
return converter(self.iloc[0])
107-
raise TypeError("cannot convert the series to {0}".format(str(converter)))
107+
raise TypeError(f"cannot convert the series to {converter}")
108108

109-
wrapper.__name__ = "__{name}__".format(name=converter.__name__)
109+
wrapper.__name__ = f"__{converter.__name__}__"
110110
return wrapper
111111

112112

@@ -274,8 +274,8 @@ def __init__(
274274
try:
275275
if len(index) != len(data):
276276
raise ValueError(
277-
"Length of passed values is {val}, "
278-
"index implies {ind}".format(val=len(data), ind=len(index))
277+
f"Length of passed values is {len(data)}, "
278+
f"index implies {len(index)}."
279279
)
280280
except TypeError:
281281
pass
@@ -1453,7 +1453,7 @@ def items(self):
14531453
--------
14541454
>>> s = pd.Series(['A', 'B', 'C'])
14551455
>>> for index, value in s.items():
1456-
... print("Index : {}, Value : {}".format(index, value))
1456+
... print(f"Index : {index}, Value : {value}")
14571457
Index : 0, Value : A
14581458
Index : 1, Value : B
14591459
Index : 2, Value : C
@@ -2160,7 +2160,7 @@ def corr(self, other, method="pearson", min_periods=None):
21602160
raise ValueError(
21612161
"method must be either 'pearson', "
21622162
"'spearman', 'kendall', or a callable, "
2163-
"'{method}' was supplied".format(method=method)
2163+
f"'{method}' was supplied"
21642164
)
21652165

21662166
def cov(self, other, min_periods=None):
@@ -2876,7 +2876,7 @@ def _try_kind_sort(arr):
28762876
sortedIdx[n:] = idx[good][argsorted]
28772877
sortedIdx[:n] = idx[bad]
28782878
else:
2879-
raise ValueError(f"invalid na_position: {repr(na_position)}")
2879+
raise ValueError(f"invalid na_position: {na_position}")
28802880

28812881
result = self._constructor(arr[sortedIdx], index=self.index[sortedIdx])
28822882

@@ -3768,7 +3768,7 @@ def _reduce(
37683768
elif isinstance(delegate, np.ndarray):
37693769
if numeric_only:
37703770
raise NotImplementedError(
3771-
"Series.{0} does not implement numeric_only.".format(name)
3771+
f"Series.{name} does not implement numeric_only."
37723772
)
37733773
with np.errstate(all="ignore"):
37743774
return op(delegate, skipna=skipna, **kwds)

0 commit comments

Comments
 (0)