2024-04-26 06:45:22 发布
网友
我有一个包含3列和百万行的pandas数据帧:
time longitude latitude 1 x1 y1 2 x2 y2 3 x3 y3 ...
我想应用一个函数来计算基于经度和纬度的距离。基本上我需要一种方法来表达函数,可以处理dataframe中两个相邻的行 像
我知道有一些方法可以沿轴1和轴0应用函数,但它们似乎只适用于单行或列。如何表达包含多行或多列的内容。在
Apply无法执行此操作,但您可以执行以下简单操作:
def compute_distance(df): next_df = df.shift(-1) return distance_on_unit_sphere(df["lat"], df["long"], next_df["lat"], next_df["long"]):
从这里开始 http://www.johndcook.com/python_longitude_latitude.html
Apply无法执行此操作,但您可以执行以下简单操作:
从这里开始 http://www.johndcook.com/python_longitude_latitude.html
相关问题 更多 >
编程相关推荐