def add_hit_rank(df):
    """Adds the rank/index of each connection to the dataframe.
    This column will later be used to create a full list of hits.

    Parameters
    ----------
    df : sub-grouped dataframe from the similarity_melted_df

    Returns
    -------
    dataframe with added rank column

    """
    # rank all compounds by their similarity
    df = df.sort_values(["similarity_metric"], ascending=False)
    # and assign the index/order to the rank column
    df = df.assign(rank=range(len(df)))
    return df