Answers for "use of lambda with if and loop in python"

5

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
0

Lambda Functions using for loop

list1 = [1,2,3,4,5]
list2 = []

for i in list1:
    f = lambda i: i /2
    list2.append(f(i))
print(list2)
Posted by: Guest on July-13-2021

Code answers related to "use of lambda with if and loop in python"

Python Answers by Framework

Browse Popular Code Answers by Language