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

Peartree needs update to work with newest pandas #156

Closed thePaulBurger closed 4 years ago

thePaulBurger commented 4 years ago

OS: Ubuntu 18.04.3 LTS Python Version: 3.6.8 Data:sample-feed.zip Example Code: $ virtualenv --python=/usr/bin/python3.6 test $ source test/bin/activate $ pip install peartree $ pip install ipython $ ipython

Python Code: import peartree as pt feed = pt.get_representative_feed("sample-feed.zip")
start = 76060 end = 106060 G = pt.load_feed_as_graph(feed, start, end) G = pt.load_feed_as_graph(feed, start, end)


AttributeError Traceback (most recent call last)

in ----> 1 G = pt.load_feed_as_graph(feed, start, end) ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/paths.py in load_feed_as_graph(feed, start_time, end_time, name, existing_graph, connection_threshold, walk_speed_kmph, stop_cost_method, fallback_stop_cost, interpolate_times, impute_walk_transfers, use_multiprocessing) 218 interpolate_times, 219 stop_cost_method, --> 220 use_multiprocessing) 221 222 # This is a flag used to check if we need to run any additional steps ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/graph.py in generate_summary_graph_elements(feed, target_time_start, target_time_end, fallback_stop_cost, interpolate_times, stop_cost_method, use_multiprocessing) 116 interpolate_times, 117 stop_cost_method, --> 118 use_multiprocessing) 119 120 # Same sanity checks on the output before we continue ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/summarizer.py in generate_edge_and_wait_values(feed, target_time_start, target_time_end, interpolate_times, stop_cost_method, use_multiprocessing) 478 stop_times = _linearly_interpolate_infill_times( 479 sub_stop_times, --> 480 use_multiprocessing) 481 else: 482 stop_times = sub_stop_times.copy() ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/summarizer.py in _linearly_interpolate_infill_times(stop_times_orig_df, use_multiprocessing) 291 trip_times_interpolator = TripTimesInterpolator(stops_times_df) 292 results = [trip_times_interpolator.generate_infilled_times(trip_id) --> 293 for trip_id in target_trip_ids] 294 elapsed = round(time.time() - start_time, 2) 295 log('Trip times interpolation complete. Execution time: {}s'.format( ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/summarizer.py in (.0) 291 trip_times_interpolator = TripTimesInterpolator(stops_times_df) 292 results = [trip_times_interpolator.generate_infilled_times(trip_id) --> 293 for trip_id in target_trip_ids] 294 elapsed = round(time.time() - start_time, 2) 295 log('Trip times interpolation complete. Execution time: {}s'.format( ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/parallel.py in generate_infilled_times(self, trip_id) 286 # Extract the arrival and departure times as independent arrays 287 for col in ['arrival_time', 'departure_time']: --> 288 sub_df[col] = apply_interpolation(sub_df[col]) 289 290 # Re-add the trip_id as column at this point ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/parallel.py in apply_interpolation(orig_array) 302 target_col_array = orig_array.copy() 303 nans, x = nan_helper(target_col_array) --> 304 target_col_array[nans] = np.interp(x(nans), 305 x(~nans), 306 target_col_array[~nans]) ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/peartree/toolkit.py in (z) 158 """ 159 --> 160 return (np.isnan(y), lambda z: z.nonzero()[0]) 161 162 ~/Work/Built_Environment/Public_Osmnx/test/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name) 5272 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5273 return self[name] -> 5274 return object.__getattribute__(self, name) 5275 5276 def __setattr__(self, name: str, value) -> None: AttributeError: 'Series' object has no attribute 'nonzero' --------------------------------------------------------------------------- Looking at the pandas documentation it states: Deprecated since version 0.24.0: Please use .to_numpy().nonzero() as a replacement. Doing a pip install pandas==0.23 fixed the issue. Could we update peartree to work with the latest version of Pandas.
kuanb commented 4 years ago

Sorry for the delay - I can work on a fix for this.

thePaulBurger commented 4 years ago

Thank you for your efforts on this useful project.

Regards Paul Burger

On Wed, May 27, 2020 at 7:36 PM Kuan Butts notifications@github.com wrote:

Closed #156 https://github.com/kuanb/peartree/issues/156 via #160 https://github.com/kuanb/peartree/pull/160.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kuanb/peartree/issues/156#event-3379299217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALX6J4SWH4F5QQQOXKB4OFLRTVFRDANCNFSM4K36SZYQ .