def trip_stats(gtfs, results_by_mode=False):
conn = gtfs.conn<EOL>conn.create_function("<STR_LIT>", <NUM_LIT:4>, wgs84_distance)<EOL>cur = conn.cursor()<EOL>query = '<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>'<EOL>q_result = pd.read_sql_query(query, conn)<EOL>q_result['<STR_LIT>'] = <NUM_LIT> * q_result['<STR_LIT>'] / q_result['<STR_LIT>']<EOL>q_result['<STR_LIT>'] = q_result['<STR_LIT>'] / <NUM_LIT:1000><EOL>q_result['<STR_LIT>'] = q_result['<STR_LIT>'] / <NUM_LIT><EOL>q_result = q_result.loc[q_result['<STR_LIT>'] != float("<STR_LIT>")]<EOL>if results_by_mode:<EOL><INDENT>q_results = {}<EOL>for type in q_result['<STR_LIT:type>'].unique().tolist():<EOL><INDENT>q_results[type] = q_result.loc[q_result['<STR_LIT:type>'] == type]<EOL><DEDENT>return q_results<EOL><DEDENT>else:<EOL><INDENT>return q_result<EOL><DEDENT>
Parameters
----------
gtfs: GTFS
results_by_mode: bool

Returns
-------
if results_by_mode is False:
    q_result: pandas.DataFrame
if results_by_mode is True:
    q_results: dict
        a dict with the following keys:
            [ADD HERE]