apply lambda to columns pandas code example
Example 1: lambda with two columns pandas
tp['col'] = tp.apply(lambda row: row['source'] if row['target'] in ['b', 'n'] else 'x',
axis=1)
Example 2: lambda in pandas
Series.apply(lambda x: x**2)
#x represent the cell value and x**2 is your function