Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ループを使用せずに、numpy配列の軸に沿ってk-minimum値のインデックスを返す方法はありますか?
import numpy as np x = np.array([[5, 2, 3],[1, 9, 2]]) # example data k = 2 # return the indices of the 2 smallest values np.argsort(x, axis=1)[:,0:k] # by row array([[1, 2], [0, 2]])