Skip to content

Bug behavior when checking element inclusion in non-unique MultiIndex  #7724

Closed
@tipanverella

Description

@tipanverella

I am using pandas.__version__==0.14.0.
This is my first bug report in github so excuse my possibly poorly formatted submission.

This bug report might be related to, or duplicate:

  1. multi-index indexing for 3-level index behaving mysteriously. #2646
  2. get_loc() returns integer or slice or KeyError nondeterministic in multiindex data frame #6501

It was explained to me by [http://stackoverflow.com/users/1427416/brenbarn] on the following StackOverflow question, http://stackoverflow.com/questions/24683023/having-issue-with-hierarchical-index-set-behavior/24684844#24684844

Essentially, the following behavior is not desirable:

print pd.__version__
WeirdIdx = pd.MultiIndex(levels=[[0], [1]],labels=[[0, 0], [0,0]],names=[u'X', u'Y'])
print WeirdIdx
print (0, 0) in WeirdIdx
print (1, 0) in WeirdIdx
print (100, 0) in WeirdIdx
print (100, 100) in WeirdIdx

since it prints:
0.14.0
X Y
0 1
1
True
True
True
True

despite the fact that (100,0) and (100,100) are unambiguously not part of the index.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated 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