save numpy arrays to txt
<p>I have to arrays (q, I) with different number of columns each and I want to save them in a txt file preserving the order of the columns, meaning in the txt file the arrays should be like:</p>

<pre><code>q, I0, I1, I2, ...
</code></pre>

<p>The shape of my arrays are:</p>

<pre><code>q.shape = (300, )
I.shape = (300, 12)
</code></pre>

<p>I tried this:</p>

<pre><code>save_arrays = np.array(zip(q, I))
np.savetxt('dummy.txt', save_arrays, delimiter='\t', newline='\r\n',
        fmt='%.5f', header='q [A-1]/I [a.u.]')
</code></pre>

<p>The shape of save_arrays is:</p>

<pre><code>save_arrays.shape = (300, 2)
</code></pre>

<p>It has two columns instead of 13. Those columns are the single array q and the multi-column array I.</p>

<p>Anyway, I'm getting this TypeError as well:</p>

<pre><code>TypeError: Mismatch between array dtype ('object') and format specifier ('%.5f %.5f') 
</code></pre>

<p>Any help is appreciated.</p>

<p>Try <code>save_arrays = np.hstack((q[:,np.newaxis],I))</code></p>

python arrays numpy