Skip to content

BUG/API: bug in multi-index slicing with missing indexers #7866

Closed
@jreback

Description

@jreback

I think the following could work and not raise KeyError because of a missing indexer. This would follow the API of loc which will be effectively a reindex as long as you have at least 1 found value.

s = pd.Series(np.arange(9),index=pd.MultiIndex.from_product([['A','B','C'],['foo','bar','baz']],names=['one','two'])).sortlevel()

s.loc[['A','D']]

idx = pd.IndexSlice
s.loc[idx[:,['foo','bah']]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignBugIndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions