Based on python, sort descending dataframe with pandas:
Given:
from pandas import DataFrame import pandas as pd d = {\'x\':[2,3,1,4,5], \'y\':[
You can create a temporary column to use in sort and then drop it:
df.assign(f = df['one']**2 + df['two']**2).sort_values('f').drop('f', axis=1) Out: letter one two 2 b 1 3 3 b 4 2 1 a 3 4 4 c 5 1 0 a 2 5