You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was a misunderstanding of what sort=True is supposed to do. When sort=True, the levels of the MultiIndex get sorted, but not the values. I plan to clarify the docs here.
To be honest, I don't even really understand your last sentence ;)
What do you mean with the "levels get sorted"? Do you mean the labels of one level (eg df_stacked.index.levels[-1]), or the integer codes of the levels (df_stacked.index.codes[-1]) while keeping the labels the same?
The above example might also not be the best, because I don't see any difference between sort=True vs sort=False
Ref: #53282 (comment)
When the MultiIndex levels are not sorted in ascending order,
DataFrame.stack
withsort=True
does not sort the values in the result.The text was updated successfully, but these errors were encountered: