python - 如何优化 pandas 中的 apply 函数以计算 levenshtein 距离?
问题描述
我正在尝试使用 apply 函数在两列之间找到 Levenshtein,但它非常慢。
from textdistance import levenshtein
temp['dist'] = temp.apply(lambda x: levenshtein.distance(x['address1'],x['address2']),axis=1)
733,000 行大约需要 2 分钟,我必须多次执行此操作。有没有办法使用矢量化来优化它?
解决方案
推荐阅读
- java - className 变量名是什么意思;java中的变量声明?
- python - Kubernetes python客户端:线程响应问题
- ballerina - Ballerina - 我们可以检查像 www.google.com 这样的 URL 的响应状态代码吗?
- imagemagick - imagemagick montage:插入不同大小的图像
- java - 我写了这样的实体,我得到了删除='false'的数据。我应该如何被删除='true'
- python - DataFrame 从字符串中提取整数/数字值?
- c - 为什么我们需要在 execvp 之前在管道上调用 close?
- reactjs - Firebase admin auth listAllUsers give - 无法确定项目 ID
- c# - (System.ArgumentException)值不在uwp中的另一个弹出窗口中打开弹出窗口时抛出的预期范围异常
- jmeter - JMeter:从 HTTP 请求中提取响应并将其存储在变量中