Skip to content
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

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

Closed
toobaz opened this issue Oct 3, 2017 · 1 comment · Fixed by #20770
Closed
Labels
Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Milestone

Comments

@toobaz
Copy link
Member

toobaz commented Oct 3, 2017

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.

@jreback jreback added Deprecate Functionality to remove in pandas Difficulty Intermediate Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex labels Oct 3, 2017
@jreback jreback added this to the 0.21.1 milestone Oct 3, 2017
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.21.1, 0.22.0 Nov 30, 2017
@jreback
Copy link
Contributor

jreback commented Apr 14, 2018

@toobaz would you be able to push a PR for this?

toobaz added a commit to toobaz/pandas that referenced this issue Apr 20, 2018
toobaz added a commit to toobaz/pandas that referenced this issue Apr 22, 2018
toobaz added a commit to toobaz/pandas that referenced this issue Apr 22, 2018
TomAugspurger pushed a commit that referenced this issue May 1, 2018
…20770)

* API: emit warning to raise KeyError in the future for missing keys also for MultiIndex

closes #17758
closes #20748
closes #20753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants