【发布时间】:2021-03-09 20:06:16
【问题描述】:
我有一个从 osmnx 获得的地理数据框:
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时才会出现
【问题讨论】:
-
if edges['name'].isnull():print('here')这个有用吗 -
那行不通
-
if edges['name'].iloc[i].isnull(): print('here')忘了iloc