Numpy argsort - 它在做什么? [英] Numpy argsort - what is it doing?
本文介绍了Numpy argsort - 它在做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 numpy 给出这个结果:
Why is numpy giving this result:
x = numpy.array([1.48,1.41,0.0,0.1])
print x.argsort()
>[2 3 1 0]
当我希望它这样做时:
[3 2 0 1]
显然我对这个函数的理解不够.
Clearly my understanding of the function is lacking.
推荐答案
根据 文档
返回对数组进行排序的索引.
Returns the indices that would sort an array.
2
是0.0
的索引.3
是0.1
的索引.1
是1.41
的索引.0
是1.48
的索引.2
is the index of0.0
.3
is the index of0.1
.1
is the index of1.41
.0
is the index of1.48
.
这篇关于Numpy argsort - 它在做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文