Generation

generate functionFri, 27 Jan 2023

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)

Questions about programming?Chat with your personal AI assistant