Pandas Dataframe sort by a column [duplicate]

天大地大妈咪最大 提交于 2019-12-06 04:01:32

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/46072509/pandas-dataframe-sort-by-a-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!