def compute_similarity_within_df(df, similarity_metric):
    """ Compute all pairwise similarities between the columns of df.
    Args:
        df (pandas df): size = m x n
        similarity_metric (string): "pearson" or "spearman"
    Returns:
        out_df (pandas df): size = n x n
    """
    # Compute similarity
    if similarity_metric == "pearson":
        out_df = df.corr(method="pearson")
    elif similarity_metric == "spearman":
        out_df = df.corr(method="spearman")
    else:
        err_msg = ("similarity metric must be 'pearson' or 'spearman'. " +
                   "similarity_metric: {}").format(similarity_metric)
        raise(Exception(err_msg))

    return out_df