Nov-14-2017, 09:05 PM
(This post was last modified: Nov-14-2017, 09:07 PM by PythonNewbie.)
(Nov-13-2017, 07:13 PM)DeaD_EyE Wrote:(Nov-13-2017, 10:16 AM)PythonNewbie Wrote: I noticed that argsort()[:1] returns an array, while argmin() returns a scalar.
indx_argmin()
returns an integer.
x.argsort()
returns an array and then you're accessing a slice with[:k]
which still returns an array.
Right, but what I am trying to do is select the indices of the k smallest numbers instead of the index of the smallest number as a generalization. I wanted to test the general function argsort()[:k] by putting k = 1 and compare the results to that of argmin(), but the results were different. Why? and how can I fix it?
(Nov-13-2017, 05:46 PM)Larz60+ Wrote: you can get the max of a list with:
max(x)
But I don't want the max of a list. I want the indices of the k smallest numbers in an array.