You can get like this:
data[(np.fabs(data-6.6)).argmin(axis=0)]
output:
6.7
- find the absolute diff on each element
- Find the minimum from the result and get the element from index
EDIT: for 2d:
If it is python 2.x:
map(lambda x:x[(np.fabs(x-6.6)).argmin(axis=0)], data)
python 3.x:
[r for r in map(lambda x:x[(np.fabs(x-6.6)).argmin(axis=0)], data)]
results in returning nearest value in each row.
One value from all:
data=data.flatten()
print data[(np.fabs(data-6.6)).argmin(axis=0)]
index position from each row:
ip = map(lambda x:(np.fabs(x-6.6)).argmin(axis=0), data)