Bondify / gtfs_functions

Package with useful functions to create geo-spatial visualizations from a GTFS.
MIT License
114 stars 30 forks source link

Trying to use gtfs feeds with missing fields (e.g. shape_id) crashes Pandas #8

Closed Rikuoja closed 2 years ago

Rikuoja commented 2 years ago

When using gtfs feeds such as the German gtfs feed (https://gtfs.de/de/feeds/de_nv/) or Estonia (http://peatus.ee/gtfs/) with missing shape_ids or other missing fields, import_gtfs crashes with KeyError at https://github.com/Bondify/gtfs_functions/blob/master/gtfs_functions/gtfs_funtions.py#L91

This is due to Pandas not supporting .loc if any of the keys are missing in Pandas 1.0.0 and above: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#indexing-with-list-with-missing-labels-is-deprecated

Instead, reindex should be used. Will make a PR to fix this.

Rikuoja commented 2 years ago

Apparently the same issue as https://github.com/Bondify/gtfs_functions/issues/7