Skip to content

Commit 0be9a18

Browse files
committed
BUG: Fix Series.str.contains with compiled regex on Arrow string dtype (#61942) and add whatsnew note
1 parent 702384d commit 0be9a18

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/strings/test_strings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ def test_empty_str_methods(any_string_dtype):
176176
tm.assert_series_equal(empty_str, empty.str.translate(table))
177177

178178

179+
@pytest.mark.parametrize("dtype", ["string[pyarrow]"])
180+
def test_str_contains_compiled_regex_arrow_dtype(dtype):
181+
ser = Series(["foo", "bar", "baz"], dtype=dtype)
182+
pat = re.compile("ba.")
183+
result = ser.str.contains(pat)
184+
assert str(result.dtype) == "bool[pyarrow]"
185+
expected = Series([False, True, True], dtype="bool[pyarrow]")
186+
tm.assert_series_equal(result, expected)
187+
188+
179189
@pytest.mark.parametrize(
180190
"method, expected",
181191
[

0 commit comments

Comments
 (0)