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
mi = MultiIndex(
levels=[["foo", "bar"], ["one", "two"], ["a", "b"]],
codes=[[0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0]],
names=["first", "second", "third"],
)
s = Series(0, index=mi)
unstacked = s.unstack([1, 2])
print(unstacked)
# second one two
# third b a
# first
# foo 0 0
# bar 0 0
result = unstacked.stack(0)
print(result)
# third a b
# first second
# foo one NaN 0.0
# two 0.0 NaN
# bar one NaN 0.0
# two 0.0 NaN
The expected result should have the columns b and then a, the order in the original DataFrame.
The text was updated successfully, but these errors were encountered:
The expected result should have the columns
b
and thena
, the order in the original DataFrame.The text was updated successfully, but these errors were encountered: