Skip to content

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 29, 2024

@phofl phofl added the NA - MaskedArrays Related to pd.NA and nullable extension arrays label Jan 29, 2024
@phofl phofl added this to the 2.2.1 milestone Jan 29, 2024
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Needs a whatsnew otherwise LGTM

@lukemanley
Copy link
Member

sorry to ask this here, but its somewhat related. Should the following return pd.NA or np.nan for the na_value? It is returning pd.NA but that isn't allowed in a float64 array:

In [1]: import pandas as pd

In [2]: from pandas.core.arrays._utils import to_numpy_dtype_inference

In [3]: from pandas._libs import lib

In [4]: arr = pd.array([1, pd.NA], dtype="int64[pyarrow]")

In [5]: to_numpy_dtype_inference(arr, dtype="float64", na_value=lib.no_default, hasna=True)
Out[5]: (dtype('float64'), <NA>)

@mroeschke
Copy link
Member

Should the following return pd.NA or np.nan for the na_value? It is returning pd.NA but that isn't allowed in a float64 array:

Personally I would expected np.nan here

# Conflicts:
#	doc/source/whatsnew/v2.2.1.rst
@phofl
Copy link
Member Author

phofl commented Feb 3, 2024

#57233

@phofl
Copy link
Member Author

phofl commented Feb 9, 2024

@mroeschke good to merge?

@mroeschke mroeschke merged commit 2474e16 into pandas-dev:main Feb 9, 2024
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the 56991 branch February 9, 2024 22:05
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Feb 9, 2024
mroeschke pushed a commit that referenced this pull request Feb 9, 2024
…ay with non-numeric dtype) (#57325)

Backport PR #57121: REGR: Fix to_numpy for masked array with non-numeric dtype

Co-authored-by: Patrick Hoefler <[email protected]>
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…v#57121)

* REGR: Fix to_numpy for masked array with non-numeric dtype

* Add whatsnew

* Update docstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: to_numpy_dtype_inference returns None when array is non-numeric and dtype isn't given
3 participants