Skip to content

GH6322, Bug on reset_index for a MultiIndex of all NaNs #15466

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

Closed
wants to merge 1 commit into from

Conversation

tzinckgraf
Copy link
Contributor

The reset_index function fails for a MultiIndex if at
least one column of the index is all NaN.

As per the comment in the issue, I tried other solutions such as putting the take under an if len(values) call, unfortunately that broke other issues downstream.
I started to investigate and it seems like a MultiIndex makes a category that ignores NaN, so the values in the reset_index is empty. After trying a few options, the if mask.all() seemed like the simplest change.

The reset_index function fails for a MultiIndex if at
least one column of the index is all NaN.
@jreback jreback closed this in bb2144a Feb 21, 2017
@jreback jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Feb 21, 2017
@jreback jreback added this to the 0.20.0 milestone Feb 21, 2017
@jreback
Copy link
Contributor

jreback commented Feb 21, 2017

thanks @tzinckgraf (you had a couple of flake issues, but I fixed on merge)

@tzinckgraf
Copy link
Contributor Author

@jreback thank you. I ran git diff master | flake8 --diff, but I must have missed something.

AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this pull request Mar 21, 2017
closes pandas-dev#6322

Author: tzinckgraf <[email protected]>

Closes pandas-dev#15466 from tzinckgraf/GH6322 and squashes the following commits:

35f97f4 [tzinckgraf] GH6322, Bug on reset_index for a MultiIndex of all NaNs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: reset_index with NaN in MultiIndex
2 participants