def filter_df(freq_df, prediction=None, top=None):
    """Filter frequency df's columns

    Parameters
    ----------
    freq_df : pandas.DataFrame
        Only a dataframe returned by `frequency_df()` should be used.
    prediction : str, list
        Allow only the class predictions that match this string or
        list of strings.
    top : int
        Allow only the `top` most frequent classes.

    Returns
    -------
    pandas.DataFrame
        Same rows as input, but a filtered subset of columns.
    """

    if prediction:
        freq_df = freq_df.loc[:, prediction]
    if top:
        freq_df = freq_df[freq_df.sum().nlargest(top).index]
    return freq_df