BUG: fully reindexing panel is incorrect when missing items · Issue #5905 · pandas-dev/pandas (original) (raw)
Fully reindexing a panel copies sub-frames when missing top-level items
IOW, this should have a nan
frame for 'Item2'
In [1]: df = DataFrame(np.random.randn(4,3))
[4]: p = Panel({ 'Item1' : df })
In [12]: p['Item2'] = np.nan
In [13]: p
Out[13]:
<class 'pandas.core.panel.Panel'>
Dimensions: 2 (items) x 4 (major_axis) x 3 (minor_axis)
Items axis: Item1 to Item2
Major_axis axis: 0 to 3
Minor_axis axis: 0 to 2
In [5]: items = ['Item1','Item2']
In [8]: major_axis = np.arange(4)
In [9]: minor_axis = np.arange(3)
In [10]: result = p.reindex(items=items,major_axis=major_axis,minor_axis=minor_axis)
In [11]: result.ix['Item2']
Out[11]:
0 1 2
0 1.420715 0.972559 -1.334794
1 -0.165063 -1.811950 -1.107652
2 -1.412676 0.376777 -0.521125
3 2.119229 1.221648 -1.078299
[4 rows x 3 columns]
In [14]: p['Item2']
Out[14]:
0 1 2
0 NaN NaN NaN
1 NaN NaN NaN
2 NaN NaN NaN
3 NaN NaN NaN
[4 rows x 3 columns]