我从osmnx获得了一个geodataframe:
cities = ox.geocode_to_gdf(['Município de Lisboa', 'Município de Oeiras', 'Município da Amadora', 'Município de Loures', 'Município de Odivelas'])
whole_polygon = cities.unary_union #unary union of both geometries
G = ox.graph_from_polygon(whole_polygon, network_type='drive', simplify=True)
G_nx = nx.relabel.convert_node_labels_to_integers(G)
nodes, edges = ox.graph_to_gdfs(G_nx, nodes=True, edges = True)
我试图确定name
列的值何时为NaN
,但由于某些原因,它无法检测到:
for i in range(len(edges)):
if edges['name'].iloc[i] == float('nan'):
print('here')
我尝试了float('NaN')
而不是代码中的内容。我检查了当name
值为NaN
时,变量实际上是一个浮点。名称列中有三种类型的值:list
、str
、float
,其中只有当值为NaN
时才使用浮点数
相关问题 更多 >
编程相关推荐