Skip to content

Commit 7f39208

Browse files
committed
fallback with older pyarrow
1 parent 33cd407 commit 7f39208

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
@@ -475,6 +475,16 @@ def _str_count(self, pat: str, flags: int = 0):
475475
result = pc.count_substring_regex(self._pa_array, pat)
476476
return self._convert_int_dtype(result)
477477

478+
def _str_find(self, sub: str, start: int = 0, end: int | None = None):
479+
if (
480+
pa_version_under13p0
481+
and not (start != 0 and end is not None)
482+
and not (start == 0 and end is None)
483+
):
484+
# https://github.com/pandas-dev/pandas/pull/59562/files#r1725688888
485+
return super()._str_find(sub, start, end)
486+
return ArrowExtensionArray._str_find(self, sub, start, end)
487+
478488
def _str_get_dummies(self, sep: str = "|"):
479489
dummies_pa, labels = ArrowExtensionArray(self._pa_array)._str_get_dummies(sep)
480490
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)