total size of new array must be unchanged
<p>I have two arrays x1 and x2, both are 1*14 arrays i am trying to zip them up and then perform reshape.</p>

<p>The code is as below ;</p>

<pre><code>x1
</code></pre>

<p>Out[122]: array([1, 2, 3, 1, 5, 6, 5, 5, 6, 7, 8, 9, 7, 9])</p>

<pre><code>x2
</code></pre>

<p>Out[123]: array([1, 3, 2, 2, 8, 6, 7, 6, 7, 1, 2, 1, 1, 3])</p>

<pre><code>X = np.array(zip(x1, x2)).reshape(2, len(x1))
</code></pre>

<p>ValueErrorTraceback (most recent call last)
 in ()
----> 1 X = np.array(zip(x1, x2)).reshape(2, len(x1))</p>

<p>ValueError: total size of new array must be unchanged</p>

<p>You are on Python 3, so <code>zip</code> is evaluated lazily. </p>

<pre><code>&gt;&gt;&gt; np.array(zip(x1,x2))
array(&lt;zip object at 0x7f76d0befe88&gt;, dtype=object)
</code></pre>

<p>You need to iterate over it:</p>

<pre><code>&gt;&gt;&gt; np.array(list(zip(x1, x2))).reshape(2, len(x1))
array([[1, 1, 2, 3, 3, 2, 1, 2, 5, 8, 6, 6, 5, 7],
       [5, 6, 6, 7, 7, 1, 8, 2, 9, 1, 7, 1, 9, 3]])
</code></pre>

python arrays numpy reshape