title: Adding a New Column/Array to a Numpy Array
body: <p>I am trying to add a column to a numpy array. Each row currently has four values, I would like each row to have five values. Below is the reproducible example which returns <code>ValueError: all the input arrays must have same number of dimensions</code> I do not understand why I get the error because <code>Y</code> has the same length as <code>X</code>, just as <code>b</code> has the same length as <code>a</code> in the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html" rel="nofollow">documentation</a>. Ultimately, I would like the most efficient way to add an array like Y to an existing array like X as a new column for each row.</p>
  
  <pre><code>import numpy as np
  from sklearn import datasets
  
  #Documentation
  a = np.array([[1, 2], [3, 4]])
  b = np.array([[5, 6]])
  c = np.concatenate((a, b.T), axis=1)
  print(c)
  
  #My Case
  iris = datasets.load_iris()
  X = iris.data
  Y = iris.target
  Z = np.concatenate((X, Y.T), axis = 1) #Is transpose necessary for single dimension array? Throws error either way
  print(Z)
  </code></pre>
  
  <p><strong>Edit:</strong> I should add that in practice what I will be working with is predicted values from a model fit from <code>sklearn</code>. So what I am particularly interested in is what the most efficient way to add the predicted values to an existing array like X, i.e. the format used by sklearn. This solution below is from M4rtini's comment, which I believe is equivalent to one of Dietrich's solutions. Is this the fastest implementation?</p>
  
  <pre><code>#My Case
  import numpy as np
  from sklearn import datasets
  from sklearn.linear_model import LinearRegression
  
  iris = datasets.load_iris()
  X = iris.data
  Y = iris.target
  model = LinearRegression()
  model.fit(X,Y)
  y_hat = model.predict(X).reshape(-1,1)
  Z = np.concatenate((X, y_hat), axis = 1)
  </code></pre>