找出numpy数组中最大的N个数的索引:

 

def findTopNindex(arr,N):
    return np.argsort(a)[::-1][:N]

测试:

test = np.array([2,5,6,3,4,6,4,8,6,5])
print(findTopNindex(test,3))

>[7 8 5 2]

 

相关文章:

  • 2021-07-11
  • 2021-05-15
  • 2021-09-27
猜你喜欢
  • 2021-06-27
  • 2022-12-23
  • 2021-06-24
  • 2021-08-03
  • 2021-12-06
  • 2021-08-30
  • 2021-05-15
相关资源
相似解决方案