File tree 3 files changed +14
-3
lines changed
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ Bug fixes
31
31
- Fixed bug in :meth: `Series.all ` and :meth: `Series.any ` not treating missing values correctly for ``dtype="string[pyarrow_numpy]" `` (:issue: `55367 `)
32
32
- Fixed bug in :meth: `Series.floordiv ` for :class: `ArrowDtype ` (:issue: `55561 `)
33
33
- Fixed bug in :meth: `Series.rank ` for ``string[pyarrow_numpy] `` dtype (:issue: `55362 `)
34
+ - Fixed bug in :meth: `Series.str.extractall ` for :class: `ArrowDtype ` dtype being converted to object (:issue: `53846 `)
34
35
- Silence ``Period[B] `` warnings introduced by :issue: `53446 ` during normal plotting activity (:issue: `55138 `)
35
36
36
37
.. ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -3449,10 +3449,9 @@ def _result_dtype(arr):
3449
3449
# when the list of values is empty.
3450
3450
from pandas .core .arrays .string_ import StringDtype
3451
3451
3452
- if isinstance (arr .dtype , StringDtype ):
3452
+ if isinstance (arr .dtype , ( ArrowDtype , StringDtype ) ):
3453
3453
return arr .dtype
3454
- else :
3455
- return object
3454
+ return object
3456
3455
3457
3456
3458
3457
def _get_single_group_name (regex : re .Pattern ) -> Hashable :
Original file line number Diff line number Diff line change 4
4
import numpy as np
5
5
import pytest
6
6
7
+ from pandas .core .dtypes .dtypes import ArrowDtype
8
+
7
9
from pandas import (
8
10
DataFrame ,
9
11
Index ,
@@ -706,3 +708,12 @@ def test_extractall_same_as_extract_subject_index(any_string_dtype):
706
708
has_match_index = s .str .extractall (pattern_one_noname )
707
709
no_match_index = has_match_index .xs (0 , level = "match" )
708
710
tm .assert_frame_equal (extract_one_noname , no_match_index )
711
+
712
+
713
+ def test_extractall_preserves_dtype ():
714
+ # Ensure that when extractall is called on a series with specific dtypes set, that
715
+ # the dtype is preserved in the resulting DataFrame's column.
716
+ pa = pytest .importorskip ("pyarrow" )
717
+
718
+ result = Series (["abc" , "ab" ], dtype = ArrowDtype (pa .string ())).str .extractall ("(ab)" )
719
+ assert result .dtypes [0 ] == "string[pyarrow]"
You can’t perform that action at this time.
0 commit comments