Skip to content

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 <tzinckgraf@gmail.com> 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

2 participants