REGR: Fix to_numpy for masked array with non-numeric dtype by phofl · Pull Request #57121 · pandas-dev/pandas (original) (raw)
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>)