python - Appending in an empty list all the values of a dict key -
i'm working graphs (with python module networkx) , task create 2 different sets 1 longitude values of nodes , 1 latitude values. when read through info of each node coordinates comes in dict form, {lat: 1234, lon: 5678}
.
this code, if print node_id
nodes, if print node_data
dictionary values of coordinates:
all_nodes = g.node node in all_nodes: node_id = node node_data = g.node[node_id]
re-edit: wasn't clear, @ bottom of above code there 2 print statement:
all_nodes = g.node node in all_nodes: node_id = node node_data = g.node[node_id] print: "node id :", node_id print: "coordinates:", node_data
this gives me output nodes id , coordinates. asked know how in 2 different sets lat , long.
if understand correctly, should trick:
lat = [node['lat'] node in nodes]
python dictionary coordinates networkx
No comments:
Post a Comment