ERR/API: raise NotImplemented for Panel broadcastables with non-scalar · Issue #7692 · pandas-dev/pandas (original) (raw)
[8]: p = Panel(np.arange(3*4*5).reshape(3,4,5),items=['ItemA','ItemB','ItemC'],major_axis=date_range('20130101',periods=4),minor_axis=list('ABCDE'))
In [9]: p
Out[9]:
<class 'pandas.core.panel.Panel'>
Dimensions: 3 (items) x 4 (major_axis) x 5 (minor_axis)
Items axis: ItemA to ItemC
Major_axis axis: 2013-01-01 00:00:00 to 2013-01-04 00:00:00
Minor_axis axis: A to E
In [10]: d = p.sum(axis=1).ix[0]
In [11]: d
Out[11]:
ItemA 30
ItemB 110
ItemC 190
Name: A, dtype: int64
In [12]: p.iloc[0]
Out[12]:
A B C D E
2013-01-01 0 1 2 3 4
2013-01-02 5 6 7 8 9
2013-01-03 10 11 12 13 14
2013-01-04 15 16 17 18 19
In [13]: p.apply(lambda x: x/d,axis=0).iloc[0]
Out[13]:
A B C D E
2013-01-01 0.000000 0.033333 0.066667 0.100000 0.133333
2013-01-02 0.166667 0.200000 0.233333 0.266667 0.300000
2013-01-03 0.333333 0.366667 0.400000 0.433333 0.466667
2013-01-04 0.500000 0.533333 0.566667 0.600000 0.633333
p.div(d,axis=0)
should raise NotImplementedError
instead of returning None
.
Of course this can/should be implemented.