diff --git a/pandas/core/sorting.py b/pandas/core/sorting.py index 82eb93dd4c879..b99ac9cc333c6 100644 --- a/pandas/core/sorting.py +++ b/pandas/core/sorting.py @@ -208,7 +208,7 @@ def lexsort_indexer(keys, orders=None, na_position="last"): cat = Categorical(key, ordered=True) if na_position not in ["last", "first"]: - raise ValueError("invalid na_position: {!r}".format(na_position)) + raise ValueError(f"invalid na_position: {na_position}") n = len(cat.categories) codes = cat.codes.copy() @@ -264,7 +264,7 @@ def nargsort(items, kind="quicksort", ascending: bool = True, na_position="last" elif na_position == "first": indexer = np.concatenate([nan_idx, indexer]) else: - raise ValueError("invalid na_position: {!r}".format(na_position)) + raise ValueError(f"invalid na_position: {na_position}") return indexer