Numpy argsort - what is it doing?

后端 未结 9 2394
礼貌的吻别
礼貌的吻别 2020-11-28 19:15

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:

9条回答
  •  Happy的楠姐
    2020-11-28 19:37

    According to the documentation

    Returns the indices that would sort an array.

    • 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.

提交回复
热议问题