Skip to content

Commit d834c21

Browse files
mroeschketopper-123
authored andcommitted
BUG: Correct .type for pyarrow.map_ and pyarrow.struct types (pandas-dev#53344)
1 parent 80d7f9d commit d834c21

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/dtypes/dtypes.py

+2
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,8 @@ def type(self):
20532053
elif pa.types.is_list(pa_type) or pa.types.is_large_list(pa_type):
20542054
return list
20552055
elif pa.types.is_map(pa_type):
2056+
return list
2057+
elif pa.types.is_struct(pa_type):
20562058
return dict
20572059
elif pa.types.is_null(pa_type):
20582060
# TODO: None? pd.NA? pa.null?

pandas/tests/extension/test_arrow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,8 @@ def test_mode_dropna_false_mode_na(data):
16041604
[pa.large_string(), str],
16051605
[pa.list_(pa.int64()), list],
16061606
[pa.large_list(pa.int64()), list],
1607-
[pa.map_(pa.string(), pa.int64()), dict],
1607+
[pa.map_(pa.string(), pa.int64()), list],
1608+
[pa.struct([("f1", pa.int8()), ("f2", pa.string())]), dict],
16081609
[pa.dictionary(pa.int64(), pa.int64()), CategoricalDtypeType],
16091610
],
16101611
)

0 commit comments

Comments
 (0)