File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1618,6 +1618,10 @@ def _replace_with_mask(
1618
1618
indices = pa .array (indices , type = pa .int64 ())
1619
1619
replacements = replacements .take (indices )
1620
1620
return cls ._if_else (mask , replacements , values )
1621
+ if isinstance (values , pa .ChunkedArray ) and pa .types .is_boolean (values .type ):
1622
+ # GH#52059 replace_with_mask segfaults for chunked array
1623
+ # https://github.com/apache/arrow/issues/34634
1624
+ values = values .combine_chunks ()
1621
1625
try :
1622
1626
return pc .replace_with_mask (values , mask , replacements )
1623
1627
except pa .ArrowNotImplementedError :
Original file line number Diff line number Diff line change @@ -2333,3 +2333,12 @@ def test_series_from_string_array(dtype):
2333
2333
ser = pd .Series (arr , dtype = dtype )
2334
2334
expected = pd .Series (ArrowExtensionArray (arr ), dtype = dtype )
2335
2335
tm .assert_series_equal (ser , expected )
2336
+
2337
+
2338
+ def test_setitem_boolean_replace_with_mask_segfault ():
2339
+ # GH#52059
2340
+ N = 145_000
2341
+ arr = ArrowExtensionArray (pa .chunked_array ([np .ones ((N ,), dtype = np .bool_ )]))
2342
+ expected = arr .copy ()
2343
+ arr [np .zeros ((N ,), dtype = np .bool_ )] = False
2344
+ assert arr ._data == expected ._data
You can’t perform that action at this time.
0 commit comments