Skip to content

Feature suggestion: allow sort_values to take a callable #23846

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

Closed
dsaxton opened this issue Nov 21, 2018 · 1 comment
Closed

Feature suggestion: allow sort_values to take a callable #23846

dsaxton opened this issue Nov 21, 2018 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@dsaxton
Copy link
Member

dsaxton commented Nov 21, 2018

I occasionally find myself wanting to sort not by the values of a Series but instead by some function of those values, so it could be quite handy to have a way of passing a callable to sort_values (perhaps just a by argument as in DataFrame.sort_values) with the idea being to sort by the return values. The same would likely be useful for DataFrame.sort_values.

A simple situation where you might want to do this would be if you want to sort by the magnitudes of the values in a Series without losing information about the sign. Another might be if the values themselves were collections, and you'd like to sort by their size, or by specific values within those collections.

Has interest in a feature like this been expressed before?

@TomAugspurger
Copy link
Contributor

#3942 I believe.

@TomAugspurger TomAugspurger added the Duplicate Report Duplicate issue or pull request label Nov 21, 2018
@TomAugspurger TomAugspurger added this to the No action milestone Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants