This is similar to Issue #1533 and I've adapted the example from there.
import numpy as np
import pandas as pd
a = pd.Panel(items=[1,2,3], major_axis=[11,22,33], minor_axis=[111,222,333])
b = pd.DataFrame(np.random.randn(2,3), index=[111,333], columns=[1,2,3])
c = pd.DataFrame(np.mat('1 2 3; 4 5 6'), index=[111,333], columns=[1,2,3])
# works now
print "\na.ix[...] before"
print a.ix[:, 22, [111, 333]]
a.ix[:, 22, [111, 333]] = b
print "\na.ix[...] after"
print a.ix[:, 22, [111, 333]]
tf = np.array([True, True, True])
tf2 = np.array([True, False, True])
# boolean indexing returns the same data
print "\na.ix[tf, ...] before"
print a.ix[tf, 22, tf2]
a.ix[tf, 22, tf2]
# but assigning to it fails
try:
a.ix[tf, 22, tf2] = c
print "\na.ix[tf, ...] after"
a.ix[tf, 22, tf2]
except Exception, e:
print e
# however if we first create view into the Panel
v = a.ix[:, 22, :]
print "\nv.ix[tf, ...] before"
print v.ix[tf2, tf]
# then assigning works
v.ix[tf2, tf] = c
print "\nv.ix[tf, ...] after"
print v.ix[tf2, tf]
print "\na.ix[tf, ...] after"
print a.ix[tf, 22, tf2]
produces output
a.ix[...] before
1 2 3
111 NaN NaN NaN
333 NaN NaN NaN
a.ix[...] after
1 2 3
111 0.329258 0.759436 -0.070773
333 0.528950 -1.276978 0.084436
a.ix[tf, ...] before
1 2 3
111 0.329258 0.759436 -0.070773
333 0.528950 -1.276978 0.084436
shape mismatch: objects cannot be broadcast to a single shape
v.ix[tf, ...] before
1 2 3
111 0.329258 0.759436 -0.070773
333 0.528950 -1.276978 0.084436
v.ix[tf, ...] after
1 2 3
111 1 2 3
333 4 5 6
a.ix[tf, ...] after
1 2 3
111 1 2 3
333 4 5 6
Comment From: jreback
not suprised....that section of code is very tricky
Comment From: jreback
closing as Panels are deprecated