pydata/pandas — pull request #8702 by stahlous (2014-11-01 18:38:12+00:00)
Title: BUG: setitem fails on mixed-type Panel4D

Trying to set a value on a mixed-type Panel4D currently fails:

In [1]: from pandas.util import testing as tmd

In [2]: p4d = tmd.makePanel4D()

In [3]: p4d['foo'] = 'bar'

In [4]: p4d.iloc[0,0,0,0] = 0
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 p4d.iloc[0,0,0,0] = 0

/home/stahlous/pd_dev/pandas/pandas/core/indexing.py in __setitem__(self, key, value)
119 indexer = self._convert_to_indexer(key, is_setter=True)
120
--> 121 self._setitem_with_indexer(indexer, value)
122
123 def _has_valid_type(self, k, axis):

/home/stahlous/pd_dev/pandas/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value)
356 # indexer here
357 if (len(labels) == 1 and
--> 358 isinstance(self.obj[labels[0]].index, MultiIndex)):
359 item = labels[0]
360 obj = self.obj[item]

/home/stahlous/pd_dev/pandas/pandas/core/generic.py in __getattr__(self, name)
1927 """
1928 if name in self._internal_names_set:
-> 1929 return object.__getattribute__(self, name)
1930 elif name in self._metadata:
1931 return object.__getattribute__(self, name)

AttributeError: 'Panel' object has no attribute 'index'

Fortunately, it looks like a simple fix. If this looks OK. I'll a note to `v0.15.1.txt` (doesn't have a GH issue number yet).

This fix is needed for my latest attempt at the fillna bug #8395.