diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b8d86d9e295fe..fa85c54eb42fa 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7792,7 +7792,7 @@ def _get_agg_axis(self, axis_num): elif axis_num == 1: return self.index else: - raise ValueError("Axis must be 0 or 1 (got %r)" % axis_num) + raise ValueError(f"Axis must be 0 or 1 (got {repr(axis_num)})") def mode(self, axis=0, numeric_only=False, dropna=True): """ diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index 7ab08040e51a7..536a1fb6ae243 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -122,18 +122,16 @@ def _convert_tolerance(self, tolerance, target): if tolerance.ndim > 0: raise ValueError( ( - "tolerance argument for %s must contain " + f"tolerance argument for {type(self).__name__} must contain " "numeric elements if it is list type" ) - % (type(self).__name__,) ) else: raise ValueError( ( - "tolerance argument for %s must be numeric " - "if it is a scalar: %r" + f"tolerance argument for {type(self).__name__} must be numeric " + f"if it is a scalar: {repr(tolerance)}" ) - % (type(self).__name__, tolerance) ) return tolerance