Skip to content

No warning is raised by MultiIndex when .loc is called with list containing missing keys #17758

Closed
@toobaz

Description

@toobaz

Code Sample, a copy-pastable example if possible

From #17295 (comment)

In [2]: pd.DataFrame([[i] for i in range(3)], index=pd.MultiIndex.from_product([[1], [5,6,7]])).loc[[(1,5), (3,7)]]
Out[2]: 
       0
1 5  0.0
3 7  NaN

Problem description

#17295 introduced a warning when obj.loc[a_list] is called with a_list containing keys not in obj.index, but only applies to flat Indexes. MultiIndexes need an analogous PR.

Expected Output

The same, but with a FutureWarning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasIndexingRelated 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