Skip to content
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

REGR: Fix to_numpy conversion for arrow ea with float dtype given #57233

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 3, 2024

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

xref #57121

@phofl phofl added this to the 2.2.1 milestone Feb 3, 2024
@phofl phofl added the Arrow pyarrow functionality label Feb 3, 2024
@lukemanley
Copy link
Member

This should fix #57093 as well.

I started something similar in #57170. Do you want to copy the test from #57170 into this PR and I'll close mine?

you might also want to include the NaT cases I have in #57170 as it will fix this which currently raises:

import pandas as pd

ser = pd.Series([1, None], dtype='Int64')
ser.astype("m8[ns]")

Comment on lines 40 to 46
elif dtype is not None:
dtype = np.dtype(dtype)
if na_value is lib.no_default and hasna and dtype.kind == "f":
na_value = np.nan
dtype_given = True
else:
dtype_given = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it is better if we write from two blocks to single block ?

else: 
  if dtype is not None:
      dtype = np.dtype(dtype)
      if na_value is lib.no_default and hasna and dtype.kind == "f":
          na_value = np.nan
  
  dtype_given = True

Copy link
Member Author

Choose a reason for hiding this comment

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

no I prefer this

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm

@phofl phofl merged commit f51bb86 into pandas-dev:main Feb 7, 2024
51 checks passed
@phofl phofl deleted the to_numpy_arr_float branch February 7, 2024 16:52
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Feb 7, 2024
@mroeschke
Copy link
Member

Does this address #57233 (comment) as well?

mroeschke pushed a commit that referenced this pull request Feb 7, 2024
… arrow ea with float dtype given) (#57294)

Backport PR #57233: REGR: Fix to_numpy conversion for arrow ea with float dtype given

Co-authored-by: Patrick Hoefler <[email protected]>
@phofl
Copy link
Member Author

phofl commented Feb 7, 2024

Yikes I missed that comment, will follow up

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

Successfully merging this pull request may close these issues.

5 participants