Python3 Lambda functions – Quick cheat sheet

On this page you will find an overview of Python 3 lambda functions, how they are used and common applications.
Python3 Lambda functions are invaluable for quick and easy data cleaning and many data related tasks and for streaming data processing.

Simple Lambda

Map Lambda

square = lambda x : x*x
print(map(square, [1,2,3,4]) #squares all elements in list

Map Lambda two lists

Filter Lambda

Define a lambda expression, which must evaluate to true, for a list element to be saved in the output list

Reduce Lambda

The reduce function allows us, to accumulate a variable, over a list of inputs. Let’s say we to implement the product function

Lambda If Else with Reduce

With this code, we can implement fizz buz in one line, but we split it up in a view lines so it is easier to understand