Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ def replace(self, pat, repl, n=-1, case=None, flags=0, regex=None):
)
if len(pat) == 1:
msg += (
" In addition, single character regular expressions will"
" In addition, single character regular expressions will "
"*not* be treated as literal strings when regex=True."
)
warnings.warn(msg, FutureWarning, stacklevel=3)
Expand Down
11 changes: 0 additions & 11 deletions pandas/tests/series/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,3 @@ def test_replace_with_compiled_regex(self):
result = s.replace({regex: "z"}, regex=True)
expected = pd.Series(["z", "b", "c"])
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("pattern", ["^.$", "."])
def test_str_replace_regex_default_raises_warning(self, pattern):
# https://github.com/pandas-dev/pandas/pull/24809
s = pd.Series(["a", "b", "c"])
msg = r"The default value of regex will change from True to False"
if len(pattern) == 1:
msg += r".*single character regular expressions.*not.*literal strings"
with tm.assert_produces_warning(FutureWarning) as w:
s.str.replace(pattern, "")
assert re.match(msg, str(w[0].message))
Loading