Skip to content

Commit 3216c4f

Browse files
Backport PR #55000 on branch 2.1.x (BUG: ArrowDtype raising for fixed size list) (#55016)
Backport PR #55000: BUG: ArrowDtype raising for fixed size list Co-authored-by: Patrick Hoefler <[email protected]>
1 parent e0534b3 commit 3216c4f

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

doc/source/whatsnew/v2.1.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Fixed regressions
2929

3030
Bug fixes
3131
~~~~~~~~~
32+
- Fixed bug for :class:`ArrowDtype` raising ``NotImplementedError`` for fixed-size list (:issue:`55000`)
3233
- Fixed bug in :meth:`DataFrame.stack` with ``future_stack=True`` and columns a non-:class:`MultiIndex` consisting of tuples (:issue:`54948`)
3334

3435
.. ---------------------------------------------------------------------------

pandas/core/dtypes/dtypes.py

+2
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,8 @@ def type(self):
21092109
return CategoricalDtypeType
21102110
elif pa.types.is_list(pa_type) or pa.types.is_large_list(pa_type):
21112111
return list
2112+
elif pa.types.is_fixed_size_list(pa_type):
2113+
return list
21122114
elif pa.types.is_map(pa_type):
21132115
return list
21142116
elif pa.types.is_struct(pa_type):

pandas/tests/extension/test_arrow.py

+9
Original file line numberDiff line numberDiff line change
@@ -3037,6 +3037,15 @@ def test_groupby_count_return_arrow_dtype(data_missing):
30373037
tm.assert_frame_equal(result, expected)
30383038

30393039

3040+
def test_fixed_size_list():
3041+
# GH#55000
3042+
ser = pd.Series(
3043+
[[1, 2], [3, 4]], dtype=ArrowDtype(pa.list_(pa.int64(), list_size=2))
3044+
)
3045+
result = ser.dtype.type
3046+
assert result == list
3047+
3048+
30403049
def test_arrowextensiondtype_dataframe_repr():
30413050
# GH 54062
30423051
df = pd.DataFrame(

0 commit comments

Comments
 (0)