lambda x: x.mean(1)[:, None] code example
Example 1: lambda x:x[1]
student_tuples = [
('john', 'A', 15),
('jane', 'B', 12),
('dave', 'B', 10),]
sorted(student_tuples, key=lambda student: student[2])
>>>>[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
Example 2: lambda x: %d % ', '.join(x) for integers
>>> nums = [1, 2, 3]
>>> magic = lambda nums: int(''.join(str(i) for i in nums))
>>> magic(nums)
123
>>> magic = lambda nums: sum(digit * 10 ** (len(nums) - 1 - i)
... for i, digit in enumerate(nums))
>>> magic(nums)
123