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

BUG: multiindex slicers requires a unique index #7106

Closed
jreback opened this issue May 13, 2014 · 0 comments · Fixed by #7107
Closed

BUG: multiindex slicers requires a unique index #7106

jreback opened this issue May 13, 2014 · 0 comments · Fixed by #7107

Comments

@jreback
Copy link
Contributor

jreback commented May 13, 2014

This is actually not required, and so should work I think
(requires lexsorting only)

In [70]: df = DataFrame(dict(A = ['foo','foo','foo','foo'], B = ['a','a','a','a'], C = [1,2,1,3], D = [1,2,3,4])).set_index(['A','B','C']).sortlevel()

In [71]: df
Out[71]: 
         D
A   B C   
foo a 1  1
      1  3
      2  2
      3  4

[4 rows x 1 columns]

In [72]: df.xs(1,level=2)
Out[72]: 
       D
A   B   
foo a  1
    a  3

[2 rows x 1 columns]

In [73]: df.loc[(slice(None),slice(None),1),:]
ValueError: MultiIndex Slicing requires a unique index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant