$ 0 0 df.loc[(df.x ** 2 + df.y ** 2).sort_values().index]after How to sort pandas dataframe by custom order on string index