Code Sample
df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]})
df = df.stack()
df.loc[0] = [0,0]
This returns
In [27]: df
Out[27]:
0 A 0
B 0
1 A 2
B 5
2 A 3
B 6
dtype: int64
Then, if I try
df.loc[0] = df.loc[1]
I get
In [29]: df
Out[29]:
0 A NaN
B NaN
1 A 2.0
B 5.0
2 A 3.0
B 6.0
dtype: float64
Expected Output
It should either raise an exception/warning, or produce the same result with df.loc[0] = df.loc[1].values
.
Comment From: jreback
duplicate of https://github.com/pandas-dev/pandas/issues/10440
a PR to fix is welcome. This should just work, but as lots of issues related to MultiIndex setting, so would welcome some help here.
Comment From: jreback
cc @toobaz
Comment From: toobaz
Yes, it is also related to #12313, which is basically the same problem when the MultiIndex
is on the columns, rather than on the rows. I'm pretty sure we want to support this eventually, but might take time.