Append/concatenate Numpy array to Numpy array
<p>I have two np arrays, one is 1 dimensional, and the other it between 0 and 8 dimensional.  I'm trying to append the multidimensional array onto the other array, as you would with a list.  I've tried <code>np.append(1dim, multidim)</code> and <code>np.concatenate([1dim, multidim])</code> but neither have worked.</p>

<pre><code>[-33.752, 150.902, 38.022, 203.0, 1.0]

[[ -33.75   150.9     39.805    0.       1.   ]
 [ -33.75   150.902   44.697    1.       1.   ]
 [ -33.75   150.905   49.054    2.       1.   ]
 [ -33.752  150.905   39.062  204.       1.   ]
 [ -33.755  150.905   40.698  406.       1.   ]
 [ -33.755  150.902   37.512  405.       1.   ]
 [ -33.755  150.9     36.249  404.       1.   ]
 [ -33.752  150.9     36.627  202.       1.   ]]
</code></pre>

<p>to become:</p>

<pre><code>[-33.752, 150.902, 38.022, 203.0, 1.0],
 [ -33.75   150.9     39.805    0.       1.   ]
 [ -33.75   150.902   44.697    1.       1.   ]
 [ -33.75   150.905   49.054    2.       1.   ]
 [ -33.752  150.905   39.062  204.       1.   ]
 [ -33.755  150.905   40.698  406.       1.   ]
 [ -33.755  150.902   37.512  405.       1.   ]
 [ -33.755  150.9     36.249  404.       1.   ]
 [ -33.752  150.9     36.627  202.       1.   ]]
</code></pre>

<p>I would like to be able to reference the multidim array by using <code>1dim[1]</code></p>

<p>You have to use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.append.html" rel="nofollow">numpy.append</a> or <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html" rel="nofollow">numpy.concatenate</a>. But careful about the shape of your array. For your case you have to define the correct shape</p>

<p>ans=np.append([[small array]],[big array], axis=0) (Note that the extra [] is for correct shape, read the numpy.append tutorial)</p>

python numpy