Skip to content

Commit d9f0aa7

Browse files
committed
fallback with older pyarrow
1 parent f7f19d3 commit d9f0aa7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pandas/core/arrays/string_arrow.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ def _str_count(self, pat: str, flags: int = 0):
416416
result = pc.count_substring_regex(self._pa_array, pat)
417417
return self._convert_int_result(result)
418418

419+
def _str_find(self, sub: str, start: int = 0, end: int | None = None):
420+
if (
421+
pa_version_under13p0
422+
and not (start != 0 and end is not None)
423+
and not (start == 0 and end is None)
424+
):
425+
# https://github.com/pandas-dev/pandas/pull/59562/files#r1725688888
426+
return super()._str_find(sub, start, end)
427+
return ArrowExtensionArray._str_find(self, sub, start, end)
428+
419429
def _str_get_dummies(self, sep: str = "|"):
420430
dummies_pa, labels = ArrowExtensionArray(self._pa_array)._str_get_dummies(sep)
421431
if len(labels) == 0:

pandas/tests/strings/test_find_replace.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import numpy as np
55
import pytest
66

7-
from pandas.compat import pa_version_under13p0
87
import pandas.util._test_decorators as td
98

109
import pandas as pd
@@ -982,22 +981,13 @@ def test_find_bad_arg_raises(any_string_dtype):
982981
ser.str.rfind(0)
983982

984983

985-
def test_find_nan(any_string_dtype, request):
984+
def test_find_nan(any_string_dtype):
986985
ser = Series(
987986
["ABCDEFG", np.nan, "DEFGHIJEF", np.nan, "XXXX"], dtype=any_string_dtype
988987
)
989988
expected_dtype = (
990989
np.float64 if is_object_or_nan_string_dtype(any_string_dtype) else "Int64"
991990
)
992-
if (
993-
pa_version_under13p0
994-
and isinstance(ser.dtype, pd.StringDtype)
995-
and ser.dtype.storage == "pyarrow"
996-
):
997-
# https://github.com/apache/arrow/issues/36311
998-
mark = pytest.mark.xfail(reason="https://github.com/apache/arrow/issues/36311")
999-
# raises pa.lib.ArrowInvalid with Negative buffer resize
1000-
request.node.add_marker(mark)
1001991

1002992
result = ser.str.find("EF")
1003993
expected = Series([4, np.nan, 1, np.nan, -1], dtype=expected_dtype)

0 commit comments

Comments
 (0)