title: Numpy append ones to matrix
body: <p>I've got a function that needs to add a column at the start of a given matrix. I've got it working:</p>
  
  <pre><code>def add_ones(X):
      return np.vstack((np.ones(X.shape[0]), X.T)).T
  </code></pre>
  
  <p>This works, but as you can see, it transposes the matrix twice. I tried it first without transposing the matrix, but it seems that <code>np.ones(m)</code> always produces a row vector that I couldn't transpose (I tried doing <code>np.ones(m).T)</code>.</p>
  
  <p>My question is, is there a better way to do this? I'm not very familiar with numpy and have no idea of the performance downfalls of transposing a matrix.</p>