找出numpy中top-n的结点

import numpy as np

def nlargest_indices(arr, n):
uniques = np.unique(arr)
threshold = uniques[-n]
return np.where(arr >= threshold)

full = np.array([[1,2,7],[4,5,6]])
x, y = nlargest_indices(full, 2)
print(x)
print(y)

你可能感兴趣的:(找出numpy中top-n的结点)