[英]speed up distance calculation in Python
How can I speed up the execution of this line:我怎样才能加快这一行的执行:
from geopy import distance
...
df['Km'] = df.apply((lambda row: distance.distance(row['coord_1'],row['coord_2']).km),axis=1)
where coord_1 and coord_2 are two large sets of coordinates.其中 coord_1 和 coord_2 是两大组坐标。
distance.distance is a geopy function ( https://github.com/geopy/geopy/blob/master/geopy/distance.py ) distance.distance 是一个 geopy 函数( https://github.com/geopy/geopy/blob/master/geopy/distance.py )
Thanking you up in advance.提前致谢。
--- Update: I found a Cython implementation of the Vincenty formula@ github.com/dmsul/cyvincenty.git. --- 更新:我发现了 Vincenty 公式的 Cython 实现@github.com/dmsul/cyvincenty.git。 It greatly sped up the performance ---
它大大加快了性能---
Replaced Geopy with a Cython implementation of the Vincenty formula@ github.com/dmsul/cyvincenty.git.用 Vincenty 公式的 Cython 实现替换 Geopy@github.com/dmsul/cyvincenty.git。
It greatly sped up the performance.它大大加快了性能。
Thanks @Kilves.谢谢@Kilves。 Your comment really put me on the right track.
你的评论真的让我走上了正轨。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.