BUG: Multi-indexed Series to Numpy fails when na_value
supplied
#45774
Labels
Milestone
na_value
supplied
#45774
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
When converting a multiindexed series to a numpy array, it works correctly when no
na_value
is specified. But when anna_value
is specified, even if the series has no NA values, it errors.Digging into this issue, when
na_value
is specified, a branch is taken which sets thena_value
in the numpy array.result[self.isna()] = na_value
However, the numpy
result
array cannot understand the multiindex of theself.isna()
multi-indexed array.The Pull Request #45775 is one possibility to address this issue.
Expected Behavior
Installed Versions
The
pd.show_versions()
produces an error, but below are the versions of the relevant packages.pandas 1.5.0.dev0+268.gbe8d1ec880 dev_0 # Installed locally
numpy 1.22.0 pypi_0 pypi
The text was updated successfully, but these errors were encountered: