Search code examples
pythonpandasdataframegeolocationlatitude-longitude

Carry out computation for coordinates in each row of pandas dataframe


I have a pandas dataframe(df) with co-ordinates (latitude(Lat), longitude(Lon)) and name of the place. I want to extract particular entries which satisfy the below condition

 acos(sin(1.3963) * sin(Lat) + cos(1.3963) * cos(Lat) * cos(Lon - (-0.6981))) <= 0.1570;

How can I compute this with df.loc ?

Attaching my df.head() screenshot df.head()


Solution

  • Try this

    df[np.arccos(np.sin(1.3963) * np.sin(df["lat"]) + np.cos(1.3963) * np.cos(df["lat"]) * np.cos(df["long"] - (-0.6981))) <= 0.1570]