对不起,这个问题太冗长了,我想不出更简洁的表达方式了
我有两个数据帧示例:
import pandas as pd
import geopandas as gpd
points = gpd.GeoDataFrame([['box', Point(1.5, 1.75), 12],
['cone', Point(3.0,2.0)], 15,
['triangle', Point(2.5,1.25), 6]],
columns=['id', 'geometry', 'value'],
geometry='geometry')
df = pd.DataFrame([['a', 12, 65.7],
['b', 6, 44],
['c', 12, 76]],
columns=['name', 'val', 'score'])
我想将点['value']中的值与df['val']中的值匹配,并将点的几何体自动附加到df中的新列
我该怎么做才是最好的
到目前为止,我必须:
geo = []
for x in points['value']:
for y in df['val']:
if x == y:
geo.append(points['geometry'][x]
但是,这显然不起作用,因为x与正确的行号不对应。我在这里要换什么?我肯定我错过了一些简单的东西
目前没有回答
相关问题 更多 >
编程相关推荐