[Numpy-discussion] getting indices for array positions

Robert Cimrman cimrman3@ntc.zcu...
Wed Feb 7 07:08:42 CST 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.


More information about the Numpy-discussion mailing list