-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
Duplicate ReportDuplicate issue or pull requestDuplicate issue or pull request
Description
Let's say I have a DataFrame of stock returns. It would be great to be able to sort easily the DataFrame by the abs
value of the returns. Currently I do this by inserting a new column and then sorting on the new column and than slicing on the original columns. This is ungainly:
ret["returns_abs"] = ret.returns.abs()
ret.sort("returns_abs", ascending=False)[["returns", "key"]]
It would be great if I could either pass a Series or a function to the sort method:
ret.sort(ret.returns.abs(), ascending=False)
or
ret.sort(lambda x: abs(x.ix["returns"], ascending=False)
Metadata
Metadata
Assignees
Labels
Duplicate ReportDuplicate issue or pull requestDuplicate issue or pull request