def pct(df, axis):

    """
    Compute percentage by normalizing based on the total sum
    :param pd.DataFrame df:
    :param int axis: 0 for rows, 1 for columns
    :return: normalized dataframe
    """

    if axis == 1:
        return df.apply(lambda x: x/df.sum(axis=axis))*100
    if axis == 0:
        return df.apply(lambda x: x/df.sum(axis=axis), axis=1)*100