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>

<p>Let's define some arrays:</p>

<pre><code>&gt;&gt;&gt; x = np.zeros((4, 1))
&gt;&gt;&gt; y = np.zeros((4))
</code></pre>

<p>As is, these arrays fail to stack:</p>

<pre><code>&gt;&gt;&gt; np.vstack((x, y))
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib/python3/dist-packages/numpy/core/shape_base.py", line 230, in vstack
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
ValueError: all the input array dimensions except for the concatenation axis must match exactly
</code></pre>

<p>However, with a simple change, they will stack:</p>

<pre><code>&gt;&gt;&gt; np.vstack((x, y[:, None]))
array([[ 0.],
       [ 0.],
       [ 0.],
       [ 0.],
       [ 0.],
       [ 0.],
       [ 0.],
       [ 0.]])
</code></pre>

<p>Alternatively:</p>

<pre><code>&gt;&gt;&gt; np.vstack((x[:, 0], y))
array([[ 0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.]])
</code></pre>

python numpy