The utils Module

gtfs_toolkit.utils.date_to_str(date, format_str='%Y%m%d', inverse=False)

Given a datetime.date object, convert it to a string in the given format and return the result. If inverse == True, then assume the given date is in the given string format and return its corresponding date object.

gtfs_toolkit.utils.downsample_routes_time_series(routes_time_series, freq)

Resample the given routes time series, which is the output of Feed.get_routes_time_series(), to the given (Pandas style) frequency. Additionally, add a new ‘mean_daily_speed’ time series to the output dictionary.

gtfs_toolkit.utils.downsample_stops_time_series(stops_time_series, freq)

Resample the given stops time series, which is the output of Feed.get_stops_time_series(), to the given (Pandas style) frequency.

gtfs_toolkit.utils.get_segment_length(linestring, p, q=None)

Given a Shapely linestring and two Shapely points or coordinate pairs, project the points onto the linestring, and return the distance along the linestring between the two points. If q is None, then return the distance from the start of the linestring to the projection of p.

gtfs_toolkit.utils.plot_routes_time_series(routes_ts_dict, big_units=True)

Given a routes time series dictionary (possibly downsampled), sum each time series over all routes, plot each series using MatplotLib, and return the resulting figure of four subplots.

gtfs_toolkit.utils.seconds_to_timestr(seconds, inverse=False)

Return the given number of integer seconds as the time string ‘%H:%M:%S’. If inverse == True, then do the inverse operation. In keeping with GTFS standards, the hours entry may be greater than 23.

gtfs_toolkit.utils.timestr_mod_24(timestr)

Given a GTFS time string in the format %H:%M:%S, return a timestring in the same format but with the hours taken modulo 24.

gtfs_toolkit.utils.weekday_to_str(weekday, inverse=False)

Given a weekday, that is, an integer in range(7), return it’s corresponding weekday name as a lowercase string. Here 0 -> ‘monday’, 1 -> ‘tuesday’, and so on. If inverse == True, then perform the inverse operation.

Previous topic

GTFS Toolkit

Next topic

The feed Module

This Page