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

UserWarning: Boolean Series key will be reindexed to match DataFrame index. #165

Closed bryanculbertson closed 3 years ago

bryanculbertson commented 3 years ago

I just upgraded to Pandas 1.2.0 on Python 3.8.5 and I am getting a warning from Pandas:

UserWarning: Boolean Series key will be reindexed to match DataFrame index.

At this line of code: https://github.com/kuanb/peartree/blob/254207ba759d82a1d66f84287075ce1f8d093463/peartree/parallel.py#L127

I think this is because the filter is using a different Dataframe from the Dataframe being filtered.

bryanculbertson commented 3 years ago

@kuanb I don't know this code, but the fix may be to change constraint_2 to use stop_times_by_stop instead:

constraint_2 = (stop_times_by_stop.direction_id == direction)
direction_subset = stop_times_by_stop[constraint_2]

https://github.com/kuanb/peartree/blob/254207ba759d82a1d66f84287075ce1f8d093463/peartree/parallel.py#L126-L127

bryanculbertson commented 3 years ago

Same warnings occur for Pandas 1.1.5

kuanb commented 3 years ago

Thanks, yeah I think the solution would be to actually access the boolean list as a numpy array rather than a pandas Series.

This would avoid even worrying about if we could swap out DataFrames (though I am 99 percent sure we can).

kuanb commented 3 years ago

I believe this should be able to address it.

bryanculbertson commented 3 years ago

Fixed by https://github.com/kuanb/peartree/pull/166