def kindex ( matrix , k ) : ix = ( np . arange ( len ( matrix ) ) , matrix . argsort ( axis = 0 ) [ k ] ) return ix
return indice in matrix python
Returns indices to select the kth nearest neighbour
def kindex(matrix, k):
    """ Returns indices to select the kth nearest neighbour"""

    ix = (np.arange(len(matrix)), matrix.argsort(axis=0)[k])
    return ix