fasttrips.Util
- class fasttrips.Util[source]
Util class.
Collect useful stuff here that doesn’t belong in any particular existing class.
- __init__()
Methods
__init__()add_new_id(input_df, id_colname, ...[, ...])Passing a
pandas.DataFrameinput_df with an ID column called id_colname, adds the numeric id as a column named newid_colname and returns it.add_numeric_column(input_df, id_colname, ...)Method to create numerical ID to map to an existing ID.
calculate_distance_miles(dataframe, ...)Given a dataframe with columns origin_lat, origin_lon, destination_lat, destination_lon, calculates the distance in miles between origin and destination based on Haversine.
calculate_pathweight_costs(df, result_col)Calculates the weighted cost for a given
pandas.DataFramegiven a impedance function and value.datetime64_formatter(x)Formatter to convert
numpy.datetime64to string that looks like HH:MM:SSdatetime64_min_formatter(x)Formatter to convert
numpy.datetime64to minutes after midnight (with two decimal places)exponential_integration(penalty_min, growth_rate)Returns the integrated value of an exponential function.
get_fast_trips_config()Adds additional nodes to the Partridge graph to support Fast Trip extension files.
get_process_mem_use_bytes()Returns the process memory usage in bytes
get_process_mem_use_str()Returns a string representing the process memory use.
logarithmic_integration(penalty_min, growth_rate)Returns the integrated value of an logarithmic function.
logistic_integration(penalty_minute, ...)Returns the integrated value of an logistic function.
merge_two_dicts(x, y)A helper method for Python 2.7 to 'zip' two dictionary objects
parse_boolean(val)parse_minutes_to_time(minutes)pretty(df)Make a pretty version of the dataframe and return it.
read_end_time(x)read_time(x[, end_of_day])remove_null_columns(input_df[, inplace])Remove columns from the dataframe if they're all null since they're not useful and make thinks harder to look at.
timedelta_formatter(x)Formatter to convert
numpy.timedelta64to string that looks like 4m 35.6swrite_dataframe(df, name, output_file[, ...])Convenience method to write a dataframe but make some of the fields more usable.
Attributes
DROP_DEBUG_COLUMNSDebug columns to drop
DROP_PATHFINDING_COLUMNSTIMEDELTA_COLUMNS_TO_UNITSMaps timedelta columns to units for
Util.write_dataframe()