我有两个数据框。一个包含properties locations,另一个包含railway stations locations。
属性数据框样本(原始数据框由约700行组成):
properties=pd.DataFrame({'propertyID':['13425','32535','43255','52521'],
'lat':[-37.79230,-37.86400,-37.85450,-37.71870],
'lon':[145.10290,145.09720,145.02190,144.94330]})
火车站数据框样本(原始数据框由约90行组成):
stations=pd.DataFrame({'stationID':['11','33','21','34','22'],
'lat':[-37.416861,-37.703293,-37.729261,-37.777764,-37.579206],
'lon':[145.005372,144.572524,144.650631,144.772304,144.728165]})
我有一个函数来计算两个位置之间的距离
from math import radians, cos, sin, asin, sqrt
def haversine(lon1, lat1, lon2, lat2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal d