Skip to content

Commit ea6cb90

Browse files
committed
fallback with older pyarrow
1 parent 2e1c930 commit ea6cb90

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

440+
def _str_find(self, sub: str, start: int = 0, end: int | None = None):
441+
if (
442+
pa_version_under13p0
443+
and not (start != 0 and end is not None)
444+
and not (start == 0 and end is None)
445+
):
446+
# https://github.com/pandas-dev/pandas/pull/59562/files#r1725688888
447+
return super()._str_find(sub, start, end)
448+
return ArrowExtensionArray._str_find(self, sub, start, end)
449+
440450
def _str_get_dummies(self, sep: str = "|"):
441451
dummies_pa, labels = ArrowExtensionArray(self._pa_array)._str_get_dummies(sep)
442452
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
@@ -940,22 +939,13 @@ def test_find_bad_arg_raises(any_string_dtype):
940939
ser.str.rfind(0)
941940

942941

943-
def test_find_nan(any_string_dtype, request):
942+
def test_find_nan(any_string_dtype):
944943
ser = Series(
945944
["ABCDEFG", np.nan, "DEFGHIJEF", np.nan, "XXXX"], dtype=any_string_dtype
946945
)
947946
expected_dtype = (
948947
np.float64 if is_object_or_nan_string_dtype(any_string_dtype) else "Int64"
949948
)
950-
if (
951-
pa_version_under13p0
952-
and isinstance(ser.dtype, pd.StringDtype)
953-
and ser.dtype.storage == "pyarrow"
954-
):
955-
# https://github.com/apache/arrow/issues/36311
956-
mark = pytest.mark.xfail(reason="https://github.com/apache/arrow/issues/36311")
957-
# raises pa.lib.ArrowInvalid with Negative buffer resize
958-
request.node.add_marker(mark)
959949

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

0 commit comments

Comments
 (0)