def encode_classes(df):
    """Encodes the output classes as integers and returns a
    dictionary of the encodings.

    Parameters
    ----------
    df    : Pandas DataFrame
        The dataframe containing the photometry of all events.

    Returns
    -------
    Pandas DataFrame
        The same dataframe with encoded column Type_ID.
    Pandas dict
        Dictionary of encoded classes.
    """
    df['Type_ID'] = df['Type'].astype('category').cat.codes
    #some clunky trickery to get the mapping from classes to values
    encoding_dict = df[['Type', 'Type_ID']].drop_duplicates(subset=['Type', 'Type_ID']).sort_values(by='Type_ID').reset_index(drop=True)['Type'].to_dict()
    return df, encoding_dict