There is a code for Pandas df4['loyal_profit'] = df4.apply(lambda x: (x.profit / x.ocup_rooms) if ['regular_customer', 'by_recommendation'] in x.how_find_us else None, axis=1) This code gives out an error. Rewrite it so that it works
def panda_function(df): df['loyal_profit'] = df.apply(lambda x: (x.profit / x.ocup_rooms) if ['regular_customer', 'by_recommendation'] in x.how_find_us else None, axis=1)