[Numpy-discussion] getting indices for array positions
Wed Feb 7 07:20:03 CST 2007
> Try searchsorted.
Thanks, but that doesn't work. Sorry, if my question wasn't clear.
To illustrate the requirement:
array([ 0. , 0.1, 0.2, 0.3, 0.4])
>>> # should be 1
>>> # should be 2
I could correct for one index position, of course, but I still have the
requirement to get the index of the item with the closest value to the key.
Since searchsorted returns the index of the first item in a that is >= or >
the key, it can't make the distinction between 0.1 and 0.2 as I would like to
Hope this clarifies my question.
More information about the Numpy-discussion