我有一个巨大的数据框
23/12/2020 15:38 23/12/2020 15:39 23/12/2020 15:40
1 [12,10] [15,10]
2 [52, 21] [14,7]
3 [1,0] [10,14]
数据框中的值对应于地理坐标。我想有一个新的数据框,它表示日期和坐标之间的平均速度。我编写了一个函数distance(wsp1, wsp2)
,它将2个坐标列表作为输入,并返回它们之间的距离。我还有一个函数,它计算两个日期之间的差值diff_between_dates(date1, date2)
。我的问题是如何创建一个新的数据帧,它在第一列中具有一行中前两个非空单元格之间的平均速度,在第二列中具有一行中第二个和第三个非空单元格之间的平均速度,依此类推。因此,在我的示例中,期望的输出是:
1
1 distance([15,10],[12,10])/diff_between_dates(23/12/2020 15:40,23/12/2020 15:39)
2 distance([52,21],[14,7])/diff_between_dates(23/12/2020 15:40,23/12/2020 15:38)
3 distance([10,14],[1,0])/diff_between_dates(23/12/2020 15:39,23/12/2020 15:38)
相关问题 更多 >
编程相关推荐