Skip to content

CLN: remove unnecessary check in MultiIndex #29437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,7 @@ def drop(self, codes, level=None, errors="raise"):
codes : array-like
Must be a list of tuples
level : int or level name, default None
errors : str, default 'raise'

Returns
-------
Expand All @@ -2172,18 +2173,11 @@ def drop(self, codes, level=None, errors="raise"):
if level is not None:
return self._drop_from_level(codes, level)

try:
if not isinstance(codes, (np.ndarray, Index)):
if not isinstance(codes, (np.ndarray, Index)):
try:
codes = com.index_labels_to_array(codes)
indexer = self.get_indexer(codes)
mask = indexer == -1
if mask.any():
if errors != "ignore":
raise ValueError(
"codes {codes} not contained in axis".format(codes=codes[mask])
)
except Exception:
pass
except ValueError:
pass

inds = []
for level_codes in codes:
Expand Down