Bondify / gtfs_functions

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

Cut gtfs error: length of values does not match length of index #14

Closed csdiehl closed 9 months ago

csdiehl commented 2 years ago

When attempting to run cut_gtfs on the attached feed, I got the following error "Length of values (25) does not match length of index (24)." It seems that the error is being thrown when attempting to concatenate two dataframes of different lengths on this line:

https://github.com/Bondify/gtfs_functions/blob/0fadd44e7f30bc5bfee379103ac6378bfbdde94a/gtfs_functions/gtfs_funtions.py#L661

I added this code in the format_shapes() function to fill the mismatching geometries with NA values, and then removed those later from the dataframe. This worked as a temporary fix for me since the problem only affected 5 routes. However, would be good to figure out what is causing the problem in the first place.

 if (len(df) == len(s['segment'])):
        df['geometry'] = s['segment']
    else:
        df['geometry'] = None

Feed: mbta_proposed.zip

Code:

routes, stops, stop_times, trips, shapes = gtfs.import_gtfs("./feeds/mbta_proposed.zip", busiest_date = True)
cut_gtfs(stop_times, stops, shapes)
Bondify commented 1 year ago

hi @csdiehl please check if the error persists with the new version of the package.