Python 3 Tutorial: How To Use If Statements In Lambda

preview_player
Показать описание
In this Python 3 Tutorial, we will look at if statements in lambda.

Be sure to like, share and comment to show your support for our tutorials.

=======================================
======================================
Рекомендации по теме
Комментарии
Автор

Thanks for this video! What if I only have one condition and I want else to do nothing?

imad_uddin
Автор

I have a question. if I want to create a new column and fill this column with values which are extracted from two of the existing columns in the same data frame, can I do this with lambda function?
below is my code, it didn't work. I spent my hours and I couldn't figure out.

intra.deaths = (lambda x, y: x if intra.side=='SideA' else y, intra.SideBDeaths, intra.SideBDeaths)

intra = my data frame
"side", "SideADeaths", "SideBDeaths" = existing columns
"deaths" = the ​new column,

huseyinyilmaz