8

I have a Python Pandas Data Frame. The df has 2 columns, I would like to sort the df by the second column.

   Kappa_prod   Angle
0   0.004511    -5.457840
1   0.003977    -5.312861
2   0.004476    -5.311292
3   0.003644    -117.579594
4   0.003306    -117.542817

I would like to sort the df by Angle (ascending order).

Ayan Mitra
  • 497
  • 1
  • 8
  • 20

1 Answers1

24

You can use this:

df.sort_values("Angle", inplace=True)

By default ascending=True is passed to the above call. For more information check the documentation here.

Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117