I have a 2D Numpy Array, and I want to apply a function to each of the rows and form a new column (the new first column) with the results. For example, let
M = np.array([[1,0,1], [0,0,1]])
and I want to apply the sum function on each row and get
array([[2,1,0,1], [1,0,0,1]])
So the first column is [2,1], the sum of the first row and the second row.
np.column_stack((M.sum(1), M))