Numpy argsort-它在做什么? [英] Numpy argsort - what is it doing?

查看:53
本文介绍了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]

当我期望它能做到这一点时:

when I'd expect it to do this:

[3 2 0 1]

[3 2 0 1]

很显然,我对该功能缺乏了解.

Clearly my understanding of the function is lacking.

推荐答案

根据

返回将对数组进行排序的索引.

Returns the indices that would sort an array.

  • 20.0的索引.
  • 30.1的索引.
  • 11.41的索引.
  • 01.48的索引.
    • 2 is the index of 0.0.
    • 3 is the index of 0.1.
    • 1 is the index of 1.41.
    • 0 is the index of 1.48.
    • 这篇关于Numpy argsort-它在做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆