If Else Statement Using Apply & Lambda


In this code snippet we use a lambda function to create if else conditional logic and use an apply function to apply this to the orders dataframe.

 1|  orders['in_promo'] = orders['PromoID'].apply(lambda x: 'N' if x == 'None' else 'Y')
Did you find this snippet useful?

Sign up for free to to add this to your code library