def flatten_columns(df, sep="_"):
    """ Completely flattens a multi-level column index

    Parameters
    ----------
    df : pandas.DataFrame
        The DataFrame with multi-level columns that will be flattened.
    sep : string, optional
        The string that will be used to delimit each level of the
        column index in the flattened names.

    Returns
    -------
    flattened : pandas.DataFrame

    """
    newcols = [sep.join(_) for _ in df.columns]
    return df.set_axis(newcols, axis="columns", inplace=False)