-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
Suppose I have:
a=Panel(items=[1,2,3],major_axis=[11,22,33],minor_axis=[111,222,333])
b=DataFrame(randn(2,3),index=[111,333],columns=[1,2,3])
I get an error when trying to assign b to a slice of a:
a.ix[:,22,[111,333]]=b
ValueError Traceback (most recent call last)
in ()
----> 1 a.ix[:,22,[111,333]]=b
/usr/local/lib/python2.7/site-packages/pandas/core/indexing.pyc in setitem(self, key, value)
66 indexer = self._convert_to_indexer(key)
67
---> 68 self._setitem_with_indexer(indexer, value)
69
70 def _convert_tuple(self, key):
/usr/local/lib/python2.7/site-packages/pandas/core/indexing.pyc in _setitem_with_indexer(self, indexer, value)
101 if isinstance(indexer, tuple):
102 indexer = _maybe_convert_ix(*indexer)
--> 103 self.obj.values[indexer] = value
104
105 def _getitem_tuple(self, tup):
ValueError: array is not broadcastable to correct shape
The slice of a and b look of same shape to me, so I do not understand the broadcasting error.
When debugging _setitem_with_indexer() I notice that the indexer returns a 2x3 array instead of 3x2, so if I do:
a.ix[:,22,[111,333]]=b.T
then it works. Is this a bug or the intended behaviour?