python
import numpy as np
X = 5 #Top 5 total values
a = np.random.randint(0, 100, 100).reshape(10, 10)
#Create a vector that sums the column elements of a matrix
sum_row_vec = np.sum(a, axis=0)
#Get the index with the highest X in the column sum
top_indecies = sum_row_vec.argsort()[-X:][::-1]
#Sort by index
np.sort(top_indecies)
top_row_a = a[:, top_indecies]
Recommended Posts