From 118dc4e1dbdc448a6704c217c6eb3f5867e0ed05 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Wed, 30 Dec 2020 08:40:51 -0700 Subject: [PATCH] MAINT: regex char class improve * remove superfluous regex character classes from the codebase (those that contain a single character incur the overhead of a class with none of the advantages of a class) * for more details, see similar change in NumPy: https://github.com/numpy/numpy/pull/18083 --- pandas/tests/test_strings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/test_strings.py b/pandas/tests/test_strings.py index 538a52d84b73a..ac9b160ab0968 100644 --- a/pandas/tests/test_strings.py +++ b/pandas/tests/test_strings.py @@ -1066,7 +1066,7 @@ def test_replace_compiled_regex(self): values = Series(["fooBAD__barBAD", np.nan]) # test with compiled regex - pat = re.compile(r"BAD[_]*") + pat = re.compile(r"BAD_*") result = values.str.replace(pat, "", regex=True) exp = Series(["foobar", np.nan]) tm.assert_series_equal(result, exp) @@ -1095,7 +1095,7 @@ def test_replace_compiled_regex(self): # case and flags provided to str.replace will have no effect # and will produce warnings values = Series(["fooBAD__barBAD__bad", np.nan]) - pat = re.compile(r"BAD[_]*") + pat = re.compile(r"BAD_*") with pytest.raises(ValueError, match="case and flags cannot be"): result = values.str.replace(pat, "", flags=re.IGNORECASE)