kuanb / peartree

peartree: A library for converting transit data into a directed graph for sketch network analysis.
MIT License
201 stars 23 forks source link

'Series' object has no attribute 'iteritems': pandas incompatibility #182

Open youcefker opened 2 months ago

youcefker commented 2 months ago

I am using the example code:

import peartree as pt

feed = pt.get_representative_feed("./gtfs.zip")
start = 7*60*60  # 7:00 AM
end = 10*60*60  # 10:00 AM

G = pt.load_feed_as_graph(feed, start, end)

these are the versions for peartree and pandas:

peartree version: 0.6.4
pandas version: 2.2.2

and this is the error I got:

[anaconda3\envs\ox\Lib\site-packages\peartree\graph.py](http://localhost:8888/lab/workspaces/auto-y/tree/~/AppData/Local/anaconda3/envs/ox/Lib/site-packages/peartree/graph.py) in ?(G, name, stops_df, exempt_nodes, connection_threshold)
    193                                           connection_threshold,
    194                                           exempt_id=full_sid)
    195 
    196         # Iterate through series results and add to output
--> 197         for node_id, dist_val in nearest_nodes.iteritems():
    198             stop_ids.append(sid)
    199             to_nodes.append(node_id)
    200             edge_costs.append(dist_val)
giancarlohc commented 2 months ago

I hope this gets patched but the workaround is to go into graph.py and change iteritems() to items(). I don't know if it breaks anything but I got peartree to plot.