Skip to content

BUG: ArrowExtensionArray.to_numpy avoid object dtype when na_value provided #54843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 1, 2023

Conversation

lukemanley
Copy link
Member

@lukemanley lukemanley added Bug Arrow pyarrow functionality labels Aug 29, 2023
result[self.isna()] = na_value
else:
if dtype is None:
empty = data._pa_array[:0].to_numpy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think data.dtype.empty._pa_array would be a "nicer" way to get an empty example to use in can_hold_element

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, thanks. updated

if data._hasna:
result[data.isna()] = na_value
elif pa.types.is_null(pa_type):
if dtype is not None and dtype.kind != "O" and isna(na_value):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to skip object here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it, not needed

@mroeschke mroeschke added this to the 2.2 milestone Sep 1, 2023
@mroeschke mroeschke merged commit bc2888d into pandas-dev:main Sep 1, 2023
@mroeschke
Copy link
Member

Thanks @lukemanley

@lukemanley lukemanley deleted the arrow-to-numpy-without-dtype branch September 6, 2023 00:53
mroeschke pushed a commit to mroeschke/pandas that referenced this pull request Sep 11, 2023
…ovided (pandas-dev#54843)

* ENH: ArrowExtensionArray.to_numpy to avoid object dtype when na_value provided

* refactor

* cleanup

* mypy

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: avoid conversion to object dtype in to_numpy for Arrow dtype and with dtype-compatible fill value
2 participants