Closed
Description
In [22]: df
Out[22]:
A A B C
0 0.148734 -0.041765 1.575866 1.422524
1 0.188963 2.086219 1.595425 0.539364
2 1.498709 -0.338857 -0.210994 0.984697
3 -0.197789 -0.093690 -0.421010 0.710587
In [23]: df.ix[:, 'D'] = ['X', 'Y', 'Z', 'V']
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-23-e2003f3ca30c> in <module>()
----> 1 df.ix[:, 'D'] = ['X', 'Y', 'Z', 'V']
/Users/changshe/code/pandas/pandas/core/indexing.pyc in __setitem__(self, key, value)
69 raise IndexingError('only tuples of length <= %d supported',
70 self.ndim)
---> 71 indexer = self._convert_tuple(key)
72 else:
73 indexer = self._convert_to_indexer(key)
/Users/changshe/code/pandas/pandas/core/indexing.pyc in _convert_tuple(self, key)
78 keyidx = []
79 for i, k in enumerate(key):
---> 80 idx = self._convert_to_indexer(k, axis=i)
81 keyidx.append(idx)
82 return tuple(keyidx)
/Users/changshe/code/pandas/pandas/core/indexing.pyc in _convert_to_indexer(self, obj, axis)
535 return indexer
536 else:
--> 537 return labels.get_loc(obj)
538
539 def _tuplify(self, loc):
/Users/changshe/code/pandas/pandas/core/index.pyc in get_loc(self, key)
716 loc : int if unique index, possibly slice or mask if not
717 """
--> 718 return self._engine.get_loc(key)
719
720 def get_value(self, series, key):
/Users/changshe/code/pandas/pandas/index.so in pandas.index.IndexEngine.get_loc (pandas/index.c:3222)()
/Users/changshe/code/pandas/pandas/index.so in pandas.index.IndexEngine.get_loc (pandas/index.c:3053)()
/Users/changshe/code/pandas/pandas/index.so in pandas.index.IndexEngine._get_loc_duplicates (pandas/index.c:3389)()
KeyError: 'D'