def tsi_norm(
    df,
    value_colname="Intensity",
    groupname_colname="sample_group_name",
    element_name="Metabolite",
):
    """
    Applies Total Sum Intensity normalization; all values will be divided by
    the sum of all values. Like that, summing up all the values would
    amount to '1'

    Parameters
    ----------
    df : pandas.DataFrame
        input dataframe, output of either the extractNamesAndIntensities()
        or the calculateMeanVarRSD() function
    columnname : string
        the name of the column with the data that needs to be
        normalized, defaults to 'Intensity'
    groupname_colname : string
        the name of the column with the sample group names,
        defaults to 'sample_group_name'
    element_name: string
        the name of the column with the identifiers of the tested elements
        (e.g. metabolites or genes). Defaults to 'Metabolite'

    Returns
    -------
    output_df : pandas.DataFrame
        the output dataframe. It follows the same architecture as
        the input dataframe, just with normalized values
    """
    pivot_df = df.pivot(
        index=element_name, columns=groupname_colname, values=value_colname
    )
    pivot_df = pivot_df.div(pivot_df.sum(axis=0), axis=1)
    output_df = (
        pivot_df.stack()  # back to original shape
        .reset_index()  # reset index, making a "0" column with intensities
        .merge(df.drop(columns=value_colname), how="right")  # add missing data
        .rename(columns={0: value_colname})  # renaming the "0" column
    )[
        df.columns
    ]  # match original column order
    return output_df