Skip to content

Commit

Permalink
Backport PR #53344: BUG: Correct .type for pyarrow.map_ and pyarrow.s…
Browse files Browse the repository at this point in the history
…truct types (#53363)

* Backport PR #53344: BUG: Correct .type for pyarrow.map_ and pyarrow.struct types

* Fix conflict
  • Loading branch information
mroeschke committed May 24, 2023
1 parent 584504c commit c8cd027
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Fixed regressions

Bug fixes
~~~~~~~~~
- 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`)
- Bug in :func:`api.interchange.from_dataframe` was raising ``IndexError`` on empty categorical data (:issue:`53077`)
- Bug in :func:`api.interchange.from_dataframe` was returning :class:`DataFrame`'s of incorrect sizes when called on slices (:issue:`52824`)
- Bug in :func:`api.interchange.from_dataframe` was unnecessarily raising on bitmasks (:issue:`49888`)
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/arrow/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def type(self):
elif pa.types.is_list(pa_type) or pa.types.is_large_list(pa_type):
return list
elif pa.types.is_map(pa_type):
return list
elif pa.types.is_struct(pa_type):
return dict
elif pa.types.is_null(pa_type):
# TODO: None? pd.NA? pa.null?
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,8 @@ def test_mode_dropna_false_mode_na(data):
[pa.large_string(), str],
[pa.list_(pa.int64()), list],
[pa.large_list(pa.int64()), list],
[pa.map_(pa.string(), pa.int64()), dict],
[pa.map_(pa.string(), pa.int64()), list],
[pa.struct([("f1", pa.int8()), ("f2", pa.string())]), dict],
[pa.dictionary(pa.int64(), pa.int64()), CategoricalDtypeType],
],
)
Expand Down

0 comments on commit c8cd027

Please sign in to comment.