how to sort subset of rows in pandas df

Solutions on MaxInterview for how to sort subset of rows in pandas df by the best coders in the world

showing results for - "how to sort subset of rows in pandas df"
Hildegard
02 Aug 2017
1In [364]: df.sort_values(['id','t'], ascending=[1,0])
2Out[364]:
3   id   t  metric_1  metric_2  metric_3
44   0  90    13.333    61.993  0.017871
53   0  89    13.333    61.998  0.017746
62   0  88    13.333    61.992  0.017711
71   0  87    13.333    61.993  0.017569
80   0  86    13.333    61.989  0.017444
99   1  90    33.333    61.736  0.030689
108   1  89    26.667    61.802  0.025995
117   1  88    20.000    61.864  0.022475
126   1  87    20.000    61.913  0.020058
135   1  86    13.333    61.964  0.018511