Skip to content

Conversation

@jreback
Copy link
Contributor

@jreback jreback commented Mar 14, 2014

closes #4370

In [3]: df = DataFrame({'one':[2,1,1,1],'two':[1,3,2,4],'three':[5,4,3,2]}) In [7]: df.columns = MultiIndex.from_tuples([('a','one'),('a','two'),('b','three')]) In [8]: df Out[8]: a b one two three 0 2 5 1 1 1 4 3 2 1 3 2 3 1 2 4 [4 rows x 3 columns] 

These are now equivalent. Used to be able to do only the 2nd.

In [9]: df.sort_index(by=('a','two')) Out[9]: a b one two three 3 1 2 4 2 1 3 2 1 1 4 3 0 2 5 1 [4 rows x 3 columns] In [10]: df.sort_index(by=[('a','two')]) Out[10]: a b one two three 3 1 2 4 2 1 3 2 1 1 4 3 0 2 5 1 [4 rows x 3 columns] 
… levels of the index, rather than requiring a list of tuple (GH4370)
@jreback jreback added this to the 0.14.0 milestone Mar 14, 2014
@jreback
Copy link
Contributor Author

jreback commented Mar 14, 2014

anyone think this is a bad idea?

@jorisvandenbossche
Copy link
Member

Looks like a good idea at first sight. Should this also be implemented for sort?

@jreback
Copy link
Contributor Author

jreback commented Mar 14, 2014

Dataframe.sort just passed thru to sort_index...but'll change the doc-string

jreback added a commit that referenced this pull request Mar 15, 2014
API: A tuple passed to DataFame.sort_index will be interpreted as the levels of the index (GH4370)
@jreback jreback merged commit b6cfeae into pandas-dev:master Mar 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment