简体   繁体   English

matlab function sortrows in python pandas dataframe

[英]matlab function sortrows in python pandas dataframe

I would like to sort a pandas dataframe, as follows:我想排序一个pandas dataframe,如下:

  1. order by first column按第一列排序
  2. if two rows are equal in the first column then, order by second column, if two rows are equal in the second column then, order by third column, and so on.如果第一列中两行相等,则按第二列排序,如果第二列中两行相等,则按第三列排序,依此类推。

I would like to obtain the same behaviour of this function in matlab ( https://it.mathworks.com/help/matlab/ref/double.sortrows.html#bt8bz9j-2 )我想在 matlab 中获得与此 function 相同的行为( https://it.mathworks.com/help/matlab/ref/double.j-sortrows.html

is there a function in pandas for this? pandas 中是否有 function 用于此?

I hope I have been clear, thanks!我希望我已经清楚了,谢谢!

In panda we have pd.DataFrame.sort_values()在熊猫中,我们有pd.DataFrame.sort_values()

out = df.sort_values(df.columns.tolist())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM