I have data frame of float numbers. I want to find closely matching number index.
df =
index value
0 10.53
1 20.23
2 12.34
3 34.12
4 5.67
5 19.56
I want to find the closely matching value index for 9.5
matc_idx = df['value'].index.get_loc(9.5)
Output:
KeyError:
How to find the closely matching index. In this case, I am expecting
print(matc_idx)
0
Previously accepted answers have used ix
which is depreciated.