-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.stack(..., dropna=False) with partial MultiIndex. #8855
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
Conversation
partial_mi = full_mi[:2] | ||
df = DataFrame(np.zeros((5, 2)), columns=partial_mi) | ||
|
||
for level in [-1, 0, 1, [0, 1], [1, 0]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a test which compares against a known result (e.g. that you are not using df.stack
to create, e.g. construct the resultant/frame series. don't need for all, maybe just say [1,0]
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, still a work in progress...
31529a0
to
f10ca8a
Compare
f10ca8a
to
c350118
Compare
Afraid I'm not set up to run vbench (on windows). Can do simple speed tests Monday or Tuesday. |
Any comments on my question at #8844 (comment)? |
You are stacking in the SAME order as presented yes (so if it happens to be sorted as is most of the time), then the output columns will be in that order, otherwise they will be in the indicated order, yes? I think that is correct and fine. Granted you almost always have a sorted MultiIndex, but it shouldn't prevent it from working. I would guarantee that input order -> output order, and not required sortedness. |
Yes, I am keeping them in the same order they appear in the MultiIndex.levels -- which is not necessarily the order in which they appear in the MultiIndex.labels. This reproduces the existing behavior when all levels are used. |
The proposed change has no effect for a super-long
With this PR:
For a super-wide
With this PR:
|
BUG: DataFrame.stack(..., dropna=False) with partial MultiIndex.
thanks! |
Closes #8844
Fixes
DataFrame.stack(..., dropna=False)
when the columns consist of a "partial"MultiIndex
, i.e. one in which thelabels
don't reference all thelevels
.