Pandas Dataframe sort by a column
29,515
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.
Author by
Ayan Mitra
Updated on September 07, 2020Comments
-
Ayan Mitra over 3 years
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).