Answers for "if in lambda python"

6

apply lambda with if

df['new column name'] = df['column name'].apply(lambda x: 'value if condition is met' if x condition else 'value if condition is not met')
Posted by: Guest on January-21-2021
7

how to use if else in lambda python

lambda <arguments> : <Return Value if condition is True> if <condition> else <Return Value if condition is False>
lambda x : True if (x > 10 and x < 20) else False
Posted by: Guest on May-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language