Skip to content

Commit 54a8ff8

Browse files
changed "fun !r" -> "repr(fun)"
As described in the following issue pandas-dev#29886 , usage of !r is currently redundant and so changing to f strings in place of it.
1 parent 6b189d7 commit 54a8ff8

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2944,7 +2944,7 @@ def _try_kind_sort(arr):
29442944
sortedIdx[n:] = idx[good][argsorted]
29452945
sortedIdx[:n] = idx[bad]
29462946
else:
2947-
raise ValueError("invalid na_position: {!r}".format(na_position))
2947+
raise ValueError(f"invalid na_position: {repr(na_position)}")
29482948

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

pandas/core/sorting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def lexsort_indexer(keys, orders=None, na_position="last"):
208208
cat = Categorical(key, ordered=True)
209209

210210
if na_position not in ["last", "first"]:
211-
raise ValueError("invalid na_position: {!r}".format(na_position))
211+
raise ValueError(f"invalid na_position: {repr(na_position)}")
212212

213213
n = len(cat.categories)
214214
codes = cat.codes.copy()
@@ -264,7 +264,7 @@ def nargsort(items, kind="quicksort", ascending: bool = True, na_position="last"
264264
elif na_position == "first":
265265
indexer = np.concatenate([nan_idx, indexer])
266266
else:
267-
raise ValueError("invalid na_position: {!r}".format(na_position))
267+
raise ValueError(f"invalid na_position: {repr(na_position)}")
268268
return indexer
269269

270270

pandas/core/strings.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1933,10 +1933,8 @@ def _forbid_nonstring_types(func):
19331933
def wrapper(self, *args, **kwargs):
19341934
if self._inferred_dtype not in allowed_types:
19351935
msg = (
1936-
"Cannot use .str.{name} with values of inferred dtype "
1937-
"{inf_type!r}.".format(
1938-
name=func_name, inf_type=self._inferred_dtype
1939-
)
1936+
f"Cannot use .str.{func_name} with values of inferred dtype "
1937+
f"{repr(self._inferred_dtype)}."
19401938
)
19411939
raise TypeError(msg)
19421940
return func(self, *args, **kwargs)

0 commit comments

Comments
 (0)