def encode_discounts(df, drop_field=True):
    """
        Discounts encoder.
        inputs:
            df: dataframe which has discounts column (pandas df series)
            drop_field: a flag if the discounts column should be dropped or not after encoding (bool)
        return:
            df: a dataframe with 3 new columns 'PROMOCODE', 'RES', 'LFG' and discounts droped if drop_field = True
    """
    df['discounts'] = df['discounts'].apply(lambda x: str(x).upper())
    df['promo_flag'] = 0
    df.loc[df['discounts'].str.contains('PROMOCODE'), 'promo_flag'] = 1
    df['resident_flag'] = 0
    df.loc[df['discounts'].str.contains(': RES'), 'resident_flag'] = 1
    df['lfg_flag'] = 0
    df.loc[df['discounts'].str.contains('LFG'), 'lfg_flag'] = 1
    if drop_field:
        df = df.drop(columns='discounts')
    return df
