def create_dicts_w_info(df,
                        table_visit_diff_string,
                        bad_records_string='num_bad_records'):
    """
    This function is used to create a dictionary that can be easily converted to a
    graphical representation based on the values for a particular dataframe
    
    Parameters
    ----------
    df (dataframe): dataframe that contains the information to be converted
    
    table_visit_diff_string (string): the column that is used to calculate the 'average'
        difference between a date of interest and the visit start date. for instance,
        this would allow someone to specify the difference between the observation
        date and the visit start date.
        
    bad_records_string (string): the column of the dataframe whose rows will be summed
        and then converted to the keys of a dictionary. for instance 'num_bad_records'
        is often used to show the total number of 'bad' (discrepant) records
        for a particular site
    
    Returns
    -------
    num_bad_records (dictionary): has the following structure
        keys: the HPOs
        values: the total number of 'bad' (discrepant) records for the particular
            column of interest
    
    table_visit_diff_dict (dictionary): has the following structure
        keys: the HPOs
        values: the 'average' difference between the two types of dates as specified
            by the table_visit_diff_string parameter. NOTE: this 'average' distance
            is ONLY for the erroneous records (and is not swayed by records where
            the two dates are concordant)
    """

    hpos = df['src_hpo_id'].unique().tolist()

    site_dictionaries = {}

    for hpo in hpos:
        sample_df = df.loc[df['src_hpo_id'] == hpo]

        sample_df.loc["Total"] = sample_df.sum(numeric_only=True)

        hpo_dict = sample_df.loc["Total"].to_dict()

        site_dictionaries[hpo] = hpo_dict

    tot = 0

    num_bad_records = {}

    for hpo, info in site_dictionaries.items():
        num_bad_records[hpo] = info[bad_records_string]

    table_visit_diff_dict = {}
    tot_rec, tot_diff = 0, 0

    for hpo, info in site_dictionaries.items():
        bad_records = info[bad_records_string]
        difference = info[table_visit_diff_string]

        tot_rec += bad_records
        tot_diff += difference

        avg = round(difference / bad_records, 2)

        table_visit_diff_dict[hpo] = avg

    table_visit_diff_dict['Total'] = round(tot_diff / tot_rec, 2)

    return num_bad_records, table_visit_diff_dict