Lambda is an important function/operator to create anonymous in-line functions in pyhton.
Basic syntax:
lamda arguments: expression
#This is our usual function where we have to define a name for the functiondef func(x,y):return(x+y)func(2,3)
5
#Lambda function add=lambda x,y:x+yadd(2,3)
5
lambda functions can be used in place of a iterator when sorting – this allows for selecting the column or the varible according to which sorting has to be done
import numpy as np np.random.seed(42)a1=np.random.choice(10,5,replace=False)file_list=[]for i in a1: file_list.append('{0}-{1}'.format('Filename',i))