Skip to content

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