UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
387 stars 83 forks source link

Memory error when Pandana network instantiation uses node df without correct node id index set #99

Open sablanchard opened 6 years ago

sablanchard commented 6 years ago

Pandana network instantiation pdna.Network() should fail gracefully when the nodes dataframe does not have the correct index set as its node id. Currently network creation function will throw a memory error when this happens. Should be easy to catch this type of issue before failure and print the problem. Example of issue:

Memory error:

nodes = pd.read_csv('nodes.csv')
edges = pd.read_csv('edges.csv')
net = pdna.Network(nodes['x'], nodes['y'], edges['from'], edges['to'], edges[['distance']])

No memory error:

nodes = pd.read_csv('nodes.csv').set_index('node_id')
edges = pd.read_csv('edges.csv')
net = pdna.Network(nodes['x'], nodes['y'], edges['from'], edges['to'], edges[['distance']])