Skip to content

API: A tuple passed to DataFame.sort_index will be interpreted as the levels of the index (GH4370) #6639

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

Merged
merged 2 commits into from
Mar 15, 2014

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ER/DOC: Sorting in multi-index columns: misleading error message, unclear docs
2 participants