矩阵降维-将矩阵按照某列进行排序
将三维矩阵转为二维矩阵
矩阵降维-将矩阵按照某列进行排序
from numpy import *
a = mat([[1,34,3],[2,3,41],[2,34,41],[2,53,41]])
print(a)
srtInd=a[:,1].argsort(0)
print(srtInd)
print(a[srtInd])
print("====")
print(a[srtInd][:,0,:])
'''
[[ 1 34 3]
[ 2 3 41]
[ 2 34 41]
[ 2 53 41]]
[[1]
[0]
[2]
[3]]
[[[ 2 3 41]]
[[ 1 34 3]]
[[ 2 34 41]]
[[ 2 53 41]]]
====
[[ 2 3 41]
[ 1 34 3]
[ 2 34 41]
[ 2 53 41]]
'''
欢迎关注我的公众号:小秋的博客
CSDN博客:https://blog.csdn.net/xiaoqiu_cr
github:https://github.com/crr121
联系邮箱:rongchen633@gmail.com
有什么问题可以给我留言噢~