Skip to content

BUG: Bug in slicing a multi-index level with an empty-list (GH8737) #8739

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

Closed
wants to merge 1 commit into from

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Nov 5, 2014

closes #8737

In [5]: multi_index = pd.MultiIndex.from_product((['foo', 'bar', 'baz'], ['alpha', 'beta']))

In [6]: df = DataFrame(np.random.randn(5, 6), index=range(5), columns=multi_index).sortlevel(0,axis=1) 

In [7]: df
Out[7]: 
        bar                 baz                 foo          
      alpha      beta     alpha      beta     alpha      beta
0 -0.725086 -0.715498  1.141087 -0.586018  0.906581 -0.260218
1 -1.111794 -0.393149  2.101567  0.648850  0.366892  0.554206
2  1.258239  1.472659 -0.174970 -0.355639 -0.843127  1.101716
3 -0.775790  0.419361 -0.521444  1.245519  0.759791  0.183877
4 -0.001001 -1.526741 -1.721501  0.527531  0.407099 -0.415245

In [8]: df.loc[:, ([], slice(None))] 
Out[8]: 
Empty DataFrame
Columns: []
Index: [0, 1, 2, 3, 4]

In [9]: df.loc[:, ([], slice(None))].columns
Out[9]: 
MultiIndex(levels=[[u'bar', u'baz', u'foo'], [u'alpha', u'beta']],
           labels=[[], []])

@jreback jreback added this to the 0.15.1 milestone Nov 5, 2014
@jreback
Copy link
Contributor Author

jreback commented Nov 5, 2014

merged via 1887ba5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for empty slice in multi indices
1 participant