data-science - 使用 Geopandas 返回多边形上的数据点
问题描述
我正在尝试获取纽约市每个行政区的出行次数,我正在使用 NYC Taxi Fare 数据集,并且已检索到 1'500,000 个数据点。问题是该程序非常缓慢,是否有其他程序来计算这些值,计算每个行政区的旅行次数。谢谢您,我将不胜感激任何评论或想法。
块引用
count=0
results=[]
for index_boro, row_boro in boroughs_gpd.iterrows():
count=0
print(row_boro.boro_name)
geom_boro = row_boro.geometry
for index_points, row_points in gdf.iterrows():
if (row_points.geometry.within(geom_boro)):
count=count+1
results.append((row_boro.boro_code,count))
break
a = tuple(results)
a
解决方案
推荐阅读
- php - 如何在 PHP 中基于某些分组将 mysql 查询的结果拆分为多个数组?
- swift - UISwitch 编辑另一个加载视图的值
- vim - 在 vim 上安装 typescript-vim 后的错误
- python - 需要在另一种方法中使用**kw(不是__init__)
- latex - 如何在表格 Latex 中使用逗号设置数字
- robots.txt - 允许文件夹,但不允许特定子文件夹
- ios - Cocoa pods 资源包 xcassets
- node.js - node.js、vue.js 和 express.js 堆栈开发
- java - Groovy - 如何创建带有变量的路径目录
- php - 表单不应包含额外字段 Symfony 4