Is there a way to return indices of k-minimum values along the axis of a numpy array without using loops?
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]])
Source: https://habr.com/ru/post/1388467/More articles:when installing setStatusBarHidden: in an iOS v5 application. The empty space remains. Is this correct? - iosProblem executing asynchronous tasks using ExecutorService - javaUnicode login in console application in Java - javaMultiple parallel browser analyzes using watir-webdriver through various browsers - ruby | fooobar.comAdding print function data to MVC3 - asp.net-mvc-3How to make the list scroll through until the last item is on top of the screen - androidCodeIgniter MSSQL join - sqlHow to compile multiple gsoap client web services into one executable? - c ++How to find disconnected nodes on neo4j with Cypher? - neo4jHow to return a "primitive Java char" from Scala? - javaAll Articles