title: Add new column to Numpy Array as a function of the rows
body: <p>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</p>
  <pre><code>M = np.array([[1,0,1], [0,0,1]])
  </code></pre>
  <p>and I want to apply the <code>sum</code> function on each row and get</p>
  <pre><code>array([[2,1,0,1], [1,0,0,1]])
  </code></pre>
  <p>So the first column is <code>[2,1]</code>, the sum of the first row and the second row.</p>