Series.drop() with boolean index: inconsistent behaviour · Issue #8530 · pandas-dev/pandas (original) (raw)
The behaviour below occurs in versions '0.15.0rc1-21-g32c5016'
and '0.14.1'
.
When the label
passed to the drop
method of a Series
is not in the index:
(a) if the index is not all booleans then an error is raised
(b) if the index is all booleans and has length > 1 then no error is raised; the original series is returned
(c) if the index is all booleans and has length == 1 then an error is raised
I propose that:
- the difference between the behaviour in (a) and (b) should be documented
- the behaviour in (c) should be changed to match that in (b)
Examples of current behaviour:
(a)
pd.Series([1, 1], index=['a', True]).drop(False) ValueError: labels [False] not contained in axis
(b)
pd.Series([1, 1], index=[True, True]).drop(False) True 1 True 1 dtype: int64
(c)
pd.Series([1], index=[True]).drop(False) ValueError: labels [False] not contained in axis