Question
Asked By – user1276273
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]
Clearly my understanding of the function is lacking.
Now we will see solution for issue: Numpy argsort – what is it doing?
Answer
According to the documentation
Returns the indices that would sort an array.
2
is the index of0.0
.3
is the index of0.1
.1
is the index of1.41
.0
is the index of1.48
.
This question is answered By – falsetru
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0