def get_route_difference_with_other_db(self, other_gtfs, start_time, end_time, uniqueness_threshold=None,<EOL>uniqueness_ratio=None):
from gtfspy.stats import frequencies_by_generated_route<EOL>this_df = frequencies_by_generated_route(self, start_time, end_time)<EOL>other_df = frequencies_by_generated_route(other_gtfs, start_time, end_time)<EOL>this_routes = {x: set(x.split('<STR_LIT:U+002C>')) for x in this_df["<STR_LIT>"]}<EOL>other_routes = {x: set(x.split('<STR_LIT:U+002C>')) for x in other_df["<STR_LIT>"]}<EOL>this_uniques = list(this_routes.keys())<EOL>other_uniques = list(other_routes.keys())<EOL>print("<STR_LIT>", len(this_uniques))<EOL>print("<STR_LIT>", len(other_uniques))<EOL>for i_key, i in this_routes.items():<EOL><INDENT>for j_key, j in other_routes.items():<EOL><INDENT>union = i | j<EOL>intersection = i & j<EOL>symmetric_difference = i ^ j<EOL>if uniqueness_ratio:<EOL><INDENT>if len(intersection) / len(union) >= uniqueness_ratio:<EOL><INDENT>try:<EOL><INDENT>this_uniques.remove(i_key)<EOL>this_df = this_df[this_df["<STR_LIT>"] != i_key]<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>other_uniques.remove(j_key)<EOL>other_df = other_df[other_df["<STR_LIT>"] != j_key]<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>print("<STR_LIT>", len(this_df))<EOL>print("<STR_LIT>", len(other_df))<EOL>return this_df, other_df<EOL>
Compares the routes based on stops in the schedule with the routes in another db and returns the ones without match.
Uniqueness thresholds or ratio can be used to allow small differences
:param uniqueness_threshold:
:param uniqueness_ratio:
:return: