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

df.sortlevel() vs df.sort_index() #7121

Closed
amelio-vazquez-reina opened this issue May 13, 2014 · 2 comments
Closed

df.sortlevel() vs df.sort_index() #7121

amelio-vazquez-reina opened this issue May 13, 2014 · 2 comments

Comments

@amelio-vazquez-reina
Copy link
Contributor

Q1: For a multi-index dataframe, what is the difference between sortlevel() and sort_index()?

As far as I can tell, for a dataframe like:

  df = pd.DataFrame({'A' : [np.random.random_integers(10) for x in xrange(500)], 
                     'B' : [np.random.random_integers(10) for x in xrange(500)], 
                     'C' : [np.random.random_integers(10) for x in xrange(500)],
                     'data' : randn(500) })

the result is the same.

Q2: Why do these methods not use the same naming convention? sort_index uses underscore to separate words, while sortlevel is just one word.

What is the official convention in Pandas? Isn't the Python convention to use underscore splitting?

@jreback
Copy link
Contributor

jreback commented May 13, 2014

related #5190

@jreback
Copy link
Contributor

jreback commented May 13, 2014

these are equivalent in this case.

sort_index is more general as it can sort by the index OR by a set of columns

sort_index could subsume sortlevel functionaility if we added a level argument.

I think that sortlevel was originally only for a multi-index and never got integrated into sort_index. as for the naming, don't know.

I'll add these comment to the issue I link which is a discussion on revising / unifying the sort API in 0.15

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

No branches or pull requests

2 participants