title: running out of memory trying to add column (np.concatenate) to numpy array, due to duplication of data
body: <p>I have this little function that adds a column to any dimension of a multidimensional ndarray (maybe more accurate to say increases the dimension on any axis).</p>
  
  <pre><code>def add_column(A, count=1, append=True, axis=-1):
      '''add extra column(s) to i'th dimension of ndarray A'''
      s = list(A.shape)
      s[axis] = count
      Z = np.zeros(s, dtype=A.dtype.type)
      if append: B = np.concatenate([A,Z], axis=axis)
      else: B = np.concatenate([Z,A], axis=axis)
      return B
  </code></pre>
  
  <p>It works fine most of the time, however if A is very large, I run out of memory because the concatenate is duplicating the data (It's not that I don't have enough memory for the larger array, I don't have memory for the larger array AND the original array at the same time). Is there a way of growing an array without duplicating the data? It's almost like what I need to do is dump A to disk, create a new array B which has the extra column, and then read A into B. This would be very slow though. Is there another way?</p>