python - 一个巨大的嵌套列表与另一个巨大的嵌套列表的元素的近似比较
问题描述
我有两个嵌套列表,其中一个包含元素。其他10K x 6
嵌套列表有28K * 15
元素。
这是我使用嵌套循环进行近似比较的伪逻辑
if nested_list_1[iter_1][0] and nested_list_1[iter_2][3] appoximate_ratio > 85:
if nested_list_1[iter_1][2] and nested_list_1[iter_2][4] appoximate_ratio > 85:
save_to_another_list
我可以使用嵌套循环遍历每个元素并进行近似比较。但这需要很多时间。有没有办法减少消耗时间?
for i in range(len(nested_list_1)): #length 10000
data_1_part_1 = nested_list_1[i][0]
data_1_part_2 = nested_list_1[i][1]
for j in range(len(nested_list_2)): #length 28000
data_2_part_1 = nested_list_2[j][9]
data_2_part_2 = nested_list_2[j][15]
if fuzzy_ratio(data_2_part_1,data_1_part_1) > 85:
if fuzzy_ratio(data_2_part_2,data_1_part_2) > 85:
writing_csv_file(nested_list_1[i])
解决方案
推荐阅读
- scala - Gatling 将数据从 feeder 传递到 exec
- ios - UIView 弹簧动画是否使用缓动曲线选项?
- three.js - 在 ThreeJS 中获取对象的全局旋转位置
- stream - HERE.OLP:如何“订阅通知”到目录?
- firefox - 如何在 Firefox 中监控 websocket 帧
- html - 如何..获取在AngularJS + HTML中检查的值“值”的检查行的总和
- powercli - PowerCli 获取存储 I/O 控制状态
- c# - C# 中的 SSIS 脚本任务错误
- python-3.x - 我正在尝试使用 python 从数据集中删除一组列
- java - 如何在 Spring 中获取实际 URL 并对其进行转换?