Skip to content

Commit 8545244

Browse files
committed
fallback with older pyarrow
1 parent 67845bf commit 8545244

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
@@ -422,6 +422,16 @@ def _str_count(self, pat: str, flags: int = 0):
422422
result = pc.count_substring_regex(self._pa_array, pat)
423423
return self._convert_int_result(result)
424424

425+
def _str_find(self, sub: str, start: int = 0, end: int | None = None):
426+
if (
427+
pa_version_under13p0
428+
and not (start != 0 and end is not None)
429+
and not (start == 0 and end is None)
430+
):
431+
# https://github.com/pandas-dev/pandas/pull/59562/files#r1725688888
432+
return super()._str_find(sub, start, end)
433+
return ArrowExtensionArray._str_find(self, sub, start, end)
434+
425435
def _str_get_dummies(self, sep: str = "|"):
426436
dummies_pa, labels = ArrowExtensionArray(self._pa_array)._str_get_dummies(sep)
427437
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)