[Numpy-discussion] getting indices for array positions
Robert Cimrman
cimrman3 at ntc.zcu.cz
Wed Feb 7 08:08:42 EST 2007
Christian Meesters wrote:
> Hi
>
> This questions might seem stupid, but I didn't get a clever solution myself,
> or found one in the archives, the cookbook, etc. . If I overlooked something,
> please give a pointer.
>
> Well, if I have an 1D array like
> [ 0. , 0.1, 0.2, 0.3, 0.4, 0.5]
> ,a scalar like 0.122 and want to retrieve the index postion of the closest
> value of the scalar in the array: Is there any fast method to get this?
Try searchsorted.
r.
More information about the NumPy-Discussion
mailing list