Feature request: sorted() methods on everything (original) (raw)

It would make Pandas easier to teach, easier to learn, and easier to use if the sorting behavior were the same between series and dataframes. But the existing order() and sort() methods are locked into their old behaviors by all of the code that already depends on them.

But a new sorted() method could bring symmetry between series and dataframes for code written from now on:

Series.sorted()      =>  same as existing Series.order()
DataFrame.sorted()   =>  same as existing DataFrame.sort()

Having this new pair of methods with identical conventions, where possible, would solve several different problems that learners have with Pandas today:

Yes, the ed at the end of sorted() would be one character longer than order() and two characters longer than the current practice of df.sort(). But, on balance, I think that most programmers would happily cede two characters in order to be able to use the same method name when they are flipping code between handling series and handling dataframes, and happy to have the option of using the standard Python name for the concept of a non-in-place sort.

I suspect that deprecating the old names would be overly disruptive at this point, and they could probably live alongside the new sorted() methods without much trouble — new documentation could adopt the new, consistent terminology where possible, if the Pandas developers did not want to disrupt current users of the old inconsistent names.