Skip to content

Conversation

proost
Copy link
Contributor

@proost proost commented Dec 20, 2019

description:
In core.base

        indexer = self.get_indexer(labels)
        mask = indexer == -1
        if mask.any():
            if errors != "ignore":
                raise KeyError(f"{labels[mask]} not found in axis")

single index check and raise if there is no matching indexer. But 'MultiIndex' case,
In indexes.multi

        codes = com.index_labels_to_array(codes)
        i = self._get_level_number(level)
        index = self.levels[i]
        values = index.get_indexer(codes)

        mask = ~algos.isin(self.codes[i], values)

        return self[mask]

no check. So i add check logic and raise exception if there is no matching indexer.
This bug cause from 'MultiIndex', so do not distinguish between "Series" and "DataFrame"

@proost proost force-pushed the bug-drop-multiindex branch from 9a4c8c9 to 7a35aad Compare December 23, 2019 09:57
@jreback jreback added this to the 1.0 milestone Dec 26, 2019
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. ping on green.

@jreback
Copy link
Contributor

jreback commented Dec 26, 2019

also needs a rebase

@proost proost force-pushed the bug-drop-multiindex branch from 7a35aad to a599970 Compare December 26, 2019 05:30
@proost proost force-pushed the bug-drop-multiindex branch from 5efe39c to 79958b7 Compare December 26, 2019 05:35
@jreback jreback merged commit 9c6771c into pandas-dev:master Dec 26, 2019
@jreback
Copy link
Contributor

jreback commented Dec 26, 2019

thanks @proost

@proost proost deleted the bug-drop-multiindex branch December 26, 2019 13:40
AlexKirko pushed a commit to AlexKirko/pandas that referenced this pull request Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.drop() with MultiIndex: inconsistent behaviour
3 participants