Closed
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
mi = MultiIndex.from_tuples([(1, 2), (2, 2), (3, 2)])
mi.drop([1, 4], level=0) # does not raise
mi.drop(4, level=0) # raises
Problem description
The docs say
Raises
KeyError
If not all of the labels are found in the selected axis
I think both statements should raise KeyError
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.drop.html
Expected Output
Both are raising KeyError: 'labels [4] not found in level'
For regular Indexes this holds True
index = Index([1, 2])
index.drop([1, 3]) # Raises
Output of pd.show_versions()
master