Stacking arrays in numpy using vstack
<p><code>array1.shape</code> gives (180, )
<code>array2.shape</code> gives (180, 1)</p>

<p>What's the difference between these two?
And because of this difference I'm unable to stack them using</p>

<pre><code>np.vstack((array2, array1))
</code></pre>

<p>What changes should I make to array1 shape so that I can stack them up?</p>

<pre><code>In [81]: x1=np.ones((10,)); x2=np.ones((10,1))
</code></pre>

<p>One array is 1d, the other 2d.  <code>vertical</code> stack requires 2 dimensions, vertical and horizontal.  So <code>np.vstack</code> passes each input through <code>np.atleast_2d</code>:</p>

<pre><code>In [82]: np.atleast_2d(x1).shape
Out[82]: (1, 10)
</code></pre>

<p>But now we have a (1,10) array and a (10,1) - they can't be joined in either axis.</p>

<p>But if we reshape <code>x1</code> so it is <code>(10,1)</code>, then we can join it with <code>x2</code> in either direction:</p>

<pre><code>In [83]: np.concatenate((x1[:,None],x2), axis=0).shape
Out[83]: (20, 1)
In [84]: np.concatenate((x1[:,None],x2), axis=1).shape
Out[84]: (10, 2)
</code></pre>

<p>Print out the two arrays:</p>

<pre><code>In [86]: x1
Out[86]: array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])
In [87]: x2
Out[87]: 
array([[ 1.],
       [ 1.],
       [ 1.],
       [ 1.],
       [ 1.],
       [ 1.],
       [ 1.],
       [ 1.],
       [ 1.],
       [ 1.]])
</code></pre>

<p>How can you concatenate those two shapes without some sort of adjustment?</p>

python numpy