Skip to content

Commit b6bcbfc

Browse files
committed
Re-restore elementwise fallback
1 parent c20e800 commit b6bcbfc

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,10 @@ def _str_rpartition(self, sep: str, expand: bool) -> Self:
23962396
def _str_slice(
23972397
self, start: int | None = None, stop: int | None = None, step: int | None = None
23982398
) -> Self:
2399+
if pa_version_under11p0:
2400+
# GH#59724
2401+
result = self._apply_elementwise(lambda val: val[start:stop:step])
2402+
return type(self)(pa.chunked_array(result))
23992403
if start is None:
24002404
if step is not None and step < 0:
24012405
# GH#59710

pandas/tests/extension/test_arrow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,12 +2036,11 @@ def test_str_join_string_type():
20362036
[None, 2, None, ["ab", None]],
20372037
[None, 2, 1, ["ab", None]],
20382038
[1, 3, 1, ["bc", None]],
2039-
pytest.param(
2039+
(
20402040
None,
20412041
None,
20422042
-1,
20432043
["dcba", None],
2044-
marks=pytest.mark.xfail(pa_version_under11p0, reason="Empty result"),
20452044
),
20462045
],
20472046
)

pandas/tests/strings/test_string_array.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pytest
33

44
from pandas._libs import lib
5-
from pandas.compat import pa_version_under11p0
65

76
from pandas import (
87
NA,
@@ -26,10 +25,6 @@ def test_string_array(nullable_string_dtype, any_string_method, request):
2625
getattr(b.str, method_name)(*args, **kwargs)
2726
return
2827

29-
if b.dtype.storage == "pyarrow" and pa_version_under11p0 and method_name == "slice":
30-
mark = pytest.mark.xfail(reason="Negative buffer resize")
31-
request.applymarker(mark)
32-
3328
expected = getattr(a.str, method_name)(*args, **kwargs)
3429
result = getattr(b.str, method_name)(*args, **kwargs)
3530

pandas/tests/strings/test_strings.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import numpy as np
77
import pytest
88

9-
from pandas.compat import pa_version_under11p0
10-
119
from pandas import (
1210
DataFrame,
1311
Index,
@@ -407,10 +405,6 @@ def test_pipe_failures(any_string_dtype):
407405
)
408406
def test_slice(start, stop, step, expected, any_string_dtype, request):
409407
ser = Series(["aafootwo", "aabartwo", np.nan, "aabazqux"], dtype=any_string_dtype)
410-
if any_string_dtype == "string[pyarrow]" and pa_version_under11p0:
411-
mark = pytest.mark.xfail(reason="Empty result")
412-
request.applymarker(mark)
413-
414408
result = ser.str.slice(start, stop, step)
415409
expected = Series(expected, dtype=any_string_dtype)
416410
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)