def find_nearest(array, value):
    idx = np.abs(array - value).argmin()
return array[idx]
array = np.random.random(10)
print(array)
value = 0.5
print(find_nearest(array, value))
find nearest value in numpy array