Closed
Description
Compare the behavior of the homogeneously typed panel1
with that of the heterogeneously types panel2
:
In [1]: import pandas as pd
In [29]: panel1 = pd.Panel([[[0., 0.]], [[0., 0.]]], items=['A', 'B'], minor_axis=['x', 'y'])
In [30]: panel2 = pd.Panel([[[0., 0.]], [['o', 'o']]], items=['A', 'B'], minor_axis=['x', 'y'])
In [33]: panel1['C'] = 0.
In [34]: panel2['C'] = 0.
In [35]: panel1.dtypes
Out[35]:
A float64
B float64
C float64
dtype: object
In [36]: panel2.dtypes
Out[36]:
A object
B object
C float64
dtype: object
In [37]: panel1.loc['C', 0, :] = [5, 6]
In [38]: panel1['C']
Out[38]:
x y
0 5 6
In [39]: panel2.loc['C', 0, :] = [5, 6]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-39-57fe49e884e4> in <module>()
----> 1 panel2.loc['C', 0, :] = [5, 6]
C:\Python34\lib\site-packages\pandas\core\indexing.py in __setitem__(self, key, value)
116 def __setitem__(self, key, value):
117 indexer = self._get_setitem_indexer(key)
--> 118 self._setitem_with_indexer(indexer, value)
119
120 def _has_valid_type(self, k, axis):
C:\Python34\lib\site-packages\pandas\core\indexing.py in _setitem_with_indexer(self, indexer, value)
460
461 if len(labels) != len(value):
--> 462 raise ValueError('Must have equal len keys and value '
463 'when setting with an iterable')
464
ValueError: Must have equal len keys and value when setting with an iterable
In [41]: pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.16.1
nose: 1.3.6
Cython: 0.22
numpy: 1.9.1
scipy: None
statsmodels: None
IPython: 3.1.0
sphinx: None
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.4
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.4.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.5
pymysql: None
psycopg2: None
Pandas 0.16.2 exhibits the same error.