From 182c68bf57d85950b78598745d959c22933bde7a Mon Sep 17 00:00:00 2001 From: jvpy Date: Wed, 4 Dec 2019 19:10:44 -0300 Subject: [PATCH 1/2] #29886 - Replace rm -rf pandas/ for repr() on parses.py --- pandas/io/parsers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 7403e6d254d03..24343d7b28680 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -913,8 +913,8 @@ def _get_options_with_defaults(self, engine): pass else: raise ValueError( - "The %r option is not supported with the" - " %r engine" % (argname, engine) + f"The {repr(argname)} option is not supported with the" + f" {repr(engine)} engine" ) else: value = _deprecated_defaults.get(argname, default) @@ -3607,8 +3607,8 @@ def __init__(self, f, colspecs, delimiter, comment, skiprows=None, infer_nrows=1 if not isinstance(self.colspecs, (tuple, list)): raise TypeError( - "column specifications must be a list or tuple, " - "input was a %r" % type(colspecs).__name__ + f"column specifications must be a list or tuple, " + f"input was a {repr(type(colspecs).__name__)}" ) for colspec in self.colspecs: From 7f24731e9625370b402ad42c16e33a757c85e9cc Mon Sep 17 00:00:00 2001 From: jvpy Date: Tue, 10 Dec 2019 21:12:54 -0300 Subject: [PATCH 2/2] fstrings on frame.py and numeric.py --- pandas/core/frame.py | 2 +- pandas/core/indexes/numeric.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index fde3d1657b4f2..964b268bc62b9 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7785,7 +7785,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