I have a GPS tracker plugged in my USB-port, now this GPS tracker gives me my current location in coordinates like this (53.545, 9.658)
. Now I also have an excel file which contains hundred of similar coordinates. I want my code to search in that Excel file for the values that are nearest to my GPS coordinates (53.545, 9.658)
and simply print that row for me.
This is my code:
import pandas as pd
df = pd.read_excel("my_coordinates")
def closest(df, v):
return df[min(range(len(df)), key = lambda i: abs(df[i]-v))]
v = (53.545, 9.658)
print(df, v)