python - Pandas.DataFrame:如何按每行中的最大值对行进行排序
解决方案
Find max on axis=1
and sort this series of maxes. reindex
using this index.
Sample df
A B C D E F
0 95 86 29 38 79 18
1 15 8 34 46 71 50
2 29 9 78 97 83 45
3 88 25 17 83 78 77
4 40 82 3 0 78 38
df_final = df.reindex(df.max(1).sort_values(ascending=False).index)
Out[675]:
A B C D E F
2 29 9 78 97 83 45
0 95 86 29 38 79 18
3 88 25 17 83 78 77
4 40 82 3 0 78 38
1 15 8 34 46 71 50
推荐阅读
- java - 找不到动态文本的 Xpath
- laravel - Laravel api 路由未通过身份验证
- apache-storm - 风暴喷口周期逻辑
- java - JLabel 未出现在 JPanel 中
- hadoop - 打开 IgnitePath 时如何获取 InputStream(返回 HadoopIgfsSecondaryFileSystemPositionedReadable)?
- sql - 在多列中显示动态数据
- java - 为什么我的 jTable 的 setBounds 不起作用
- c# - Postgresql ODBC 错误:'on' 附近的语法不正确
- javascript - 缩小来自 html 的 angularjs 调用
- eclipse - Eclipse:将鼠标移到方法上时引发 SSLException