Series.drop regression and unexpected behaviour · Issue #5248 · pandas-dev/pandas (original) (raw)
On 0.12 stable this works:
>>> s = pandas.Series([1,1,2],index=["one","one","two"])
>>> s.drop(["one"])
two 2
dtype: int64
but a singleton silently fails:
>>> s.drop("one")
one 1
one 1
two 2
dtype: int64
except when index is unique:
>>> s = pandas.Series([1,2],index=["one","two"])
>>> s.drop("one")
two 2
dtype: int64
according to the docs, the input to drop should be array like, so i'm not sure this should be permissible.
On head, with unique index, it matches, but with non-unique:
>>> pandas.__version__
'0.12.0-892-g6830600'
>>> s = pandas.Series([1,1,2],index=["one","one","two"])
>>> s2 = s.drop(["one"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/core/generic.py", line 1133, in drop
return self.ix[tuple(slicer)]
File "pandas/core/indexing.py", line 53, in __getitem__
return self._getitem_tuple(key)
File "pandas/core/indexing.py", line 558, in _getitem_tuple
return self._multi_take(tup)
File "pandas/core/indexing.py", line 598, in _multi_take
raise self._exception
KeyError