Skip to content

f strings in core/series #30025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def _coerce_method(converter):
def wrapper(self):
if len(self) == 1:
return converter(self.iloc[0])
raise TypeError("cannot convert the series to {0}".format(str(converter)))
raise TypeError(f"cannot convert the series to {converter}")

wrapper.__name__ = "__{name}__".format(name=converter.__name__)
wrapper.__name__ = f"__{converter.__name__}__"
return wrapper


Expand Down Expand Up @@ -274,8 +274,8 @@ def __init__(
try:
if len(index) != len(data):
raise ValueError(
"Length of passed values is {val}, "
"index implies {ind}".format(val=len(data), ind=len(index))
f"Length of passed values is {len(data)}, "
f"index implies {len(index)}."
)
except TypeError:
pass
Expand Down Expand Up @@ -1464,7 +1464,7 @@ def items(self):
--------
>>> s = pd.Series(['A', 'B', 'C'])
>>> for index, value in s.items():
... print("Index : {}, Value : {}".format(index, value))
... print(f"Index : {index}, Value : {value}")
Index : 0, Value : A
Index : 1, Value : B
Index : 2, Value : C
Expand Down Expand Up @@ -2171,7 +2171,7 @@ def corr(self, other, method="pearson", min_periods=None):
raise ValueError(
"method must be either 'pearson', "
"'spearman', 'kendall', or a callable, "
"'{method}' was supplied".format(method=method)
f"'{method}' was supplied"
)

def cov(self, other, min_periods=None):
Expand Down Expand Up @@ -2887,7 +2887,7 @@ def _try_kind_sort(arr):
sortedIdx[n:] = idx[good][argsorted]
sortedIdx[:n] = idx[bad]
else:
raise ValueError(f"invalid na_position: {repr(na_position)}")
raise ValueError(f"invalid na_position: {na_position}")

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

Expand Down Expand Up @@ -3779,7 +3779,7 @@ def _reduce(
elif isinstance(delegate, np.ndarray):
if numeric_only:
raise NotImplementedError(
"Series.{0} does not implement numeric_only.".format(name)
f"Series.{name} does not implement numeric_only."
)
with np.errstate(all="ignore"):
return op(delegate, skipna=skipna, **kwds)
Expand Down