items = ['A','B']
major_axis=['a','b','c']
minor_axis=[1,2,3]
pl = pd.Panel(np.random.randn(2,3,3), items=items, major_axis=major_axis, minor_axis=minor_axis)
cond = pl['A'] > 1
can we possibly support the following reference selection (not a copy)?
pl.loc['A', cond] = ...
if not, is there a fast way to solve this?
Thank you:-)
Comment From: jreback
an operation like this is much more intuitive as a MI frame. Plus Panel
is deprecated.
In [8]: df = pl.to_frame()
In [9]: df
Out[9]:
A B
major minor
a 1 -0.805830 -0.078624
2 -0.148206 0.097413
3 1.100790 1.027117
b 1 -0.176485 0.685398
2 1.713213 -1.243896
3 0.221703 0.195936
c 1 1.830155 0.835585
2 -1.091775 1.068260
3 0.737902 -1.216132
In [10]: df[df['A'] > 1]
Out[10]:
A B
major minor
a 3 1.100790 1.027117
b 2 1.713213 -1.243896
c 1 1.830155 0.835585
Comment From: sluo1989
@jreback Thank you soooo much!!!