I have a pandas DataFrame with two columns of numbers:
index | X | Y |
---|---|---|
0 | 0.1 | 0.55 |
1 | 0.2 | 0.2 |
2 | 0.4 | 0.1 |
3 | 0.8 | 0.35 |
4 | 1 | 0.9 |
I want to find tuples of the indexes of the closest values.
For example for this dataframe I would want the result
(0,2), (1,1), (2,3), (3,4), (4,4)
I saw this link explaining how to do this for a given input, but I am wondering if there is a cleaner way to do this for my task. Thanks in Advance!