Skip to content

Commit c8cd027

Browse files
authored
Backport PR #53344: BUG: Correct .type for pyarrow.map_ and pyarrow.struct types (#53363)
* Backport PR #53344: BUG: Correct .type for pyarrow.map_ and pyarrow.struct types * Fix conflict
1 parent 584504c commit c8cd027

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

doc/source/whatsnew/v2.0.2.rst

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Fixed regressions
2525

2626
Bug fixes
2727
~~~~~~~~~
28+
- Bug in :class:`.arrays.ArrowExtensionArray` incorrectly assigning ``dict`` instead of ``list`` for ``.type`` with ``pyarrow.map_`` and raising a ``NotImplementedError`` with ``pyarrow.struct`` (:issue:`53328`)
2829
- Bug in :func:`api.interchange.from_dataframe` was raising ``IndexError`` on empty categorical data (:issue:`53077`)
2930
- Bug in :func:`api.interchange.from_dataframe` was returning :class:`DataFrame`'s of incorrect sizes when called on slices (:issue:`52824`)
3031
- Bug in :func:`api.interchange.from_dataframe` was unnecessarily raising on bitmasks (:issue:`49888`)

pandas/core/arrays/arrow/dtype.py

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ def type(self):
140140
elif pa.types.is_list(pa_type) or pa.types.is_large_list(pa_type):
141141
return list
142142
elif pa.types.is_map(pa_type):
143+
return list
144+
elif pa.types.is_struct(pa_type):
143145
return dict
144146
elif pa.types.is_null(pa_type):
145147
# TODO: None? pd.NA? pa.null?

pandas/tests/extension/test_arrow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,8 @@ def test_mode_dropna_false_mode_na(data):
15801580
[pa.large_string(), str],
15811581
[pa.list_(pa.int64()), list],
15821582
[pa.large_list(pa.int64()), list],
1583-
[pa.map_(pa.string(), pa.int64()), dict],
1583+
[pa.map_(pa.string(), pa.int64()), list],
1584+
[pa.struct([("f1", pa.int8()), ("f2", pa.string())]), dict],
15841585
[pa.dictionary(pa.int64(), pa.int64()), CategoricalDtypeType],
15851586
],
15861587
)

0 commit comments

Comments
 (0)