-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: .stack(dropna=False) looks through views incorrectly for dataframe views with multi-index columns #8844
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
Comments
Curiously doing a deep copy doesn't help:
Though specifying all levels does:
Other variants:
|
More oddities I don't understand:
|
And yet more oddities (I'd expect
|
Regarding your last comment, |
But there are no NaNs, so I'd expect them to be the same. |
this is somewhat related to this: #2770 though its an easy fix, just recompute the levels (rather than just take them as is). Index objects are shared, so you need to create a new one here. (rather than using the original and just appending levels). That's why you get the 'hidden' values showing up. |
So far as I can tell, all the problems listed above are solved by first calling the following function:
|
And I think we need to be cognizant of speed issues here as well if we are talking about recreating the entire index again, namely, how does it perform on large frames (500,000x5 DataFrame)? |
OK, I'll give it a shot, though if what I have in mind is right I don't think it will address #8850. |
OK, I think I have this more or less done, but have a question about the desired behavior of In the following example (production 0.15.1), should
|
xref #8850
In the example below,
[11]
is incorrectly reflecting columns indfa
that should not be visible todfa1
. Note that this is not a problem when the columns are not a multi-index ([5]
and[6]
), or whendropna=True
(the default;[10]
and[12]
).The text was updated successfully, but these errors were encountered: