Restructuring Array of Tuples
<p>I have an array of tuples of tuples where the second level should not be a tuple and I want to convert it all to something like a 2-d array. 
Is there a quick way to restructure from this messy 1-d to a nice clean 2-d or structured array?</p>

<p>Note: These tuples <strong>do</strong> contain various types. I would like to be able to transpose and 2-d slice etc.. this data.  </p>

<p>ie...</p>

<pre><code>[((1,-4,7.0),)
((2,-5,8.0),)
((3,-6,9.0),)]
</code></pre>

<p><em>Edited to try and accommodate issues people pointed out with the original question</em> </p>

<p>The <code>dtype</code> is important here.  The closest I can come to your display is with a nested dtype</p>

<pre><code>In [182]: dt1=np.dtype('i,i,f')
In [183]: dt=np.dtype([('a',dt1,),('b',dt1,),('c',dt1,)])

In [184]: x=np.ones(1,dtype=dt)

In [185]: print(x)
[((1, 1, 1.0), (1, 1, 1.0), (1, 1, 1.0))]
</code></pre>

<p>(no final <code>,</code>)</p>

<p>If I use the <code>repr</code> rather than print's default <code>str</code>, I see the dtype as well:</p>

<pre><code>In [186]: print(repr(x))
array([((1, 1, 1.0), (1, 1, 1.0), (1, 1, 1.0))], 
      dtype=[('a', [('f0', '&lt;i4'), ('f1', '&lt;i4'), ('f2', '&lt;f4')]), ('b', [('f0', '&lt;i4'), ('f1', '&lt;i4'), ('f2', '&lt;f4')]), ('c', [('f0', '&lt;i4'), ('f1', '&lt;i4'), ('f2', '&lt;f4')])])
</code></pre>

<p>Reshape or squeeze does not work here because it is already 1d.  <code>view</code> or <code>astype</code> can work.  Do you want to just flatten the dtype, or make it all float?  What kind of shape do you expect?  Currently each record consists of 9 numbers.</p>

<p>With a compatible dtype I can view this array as a record of 9 values:</p>

<pre><code>In [195]: dt2=np.dtype('i,i,f,i,i,f,i,i,f')
In [196]: x.view(dt2)
Out[196]: 
array([(1, 1, 1.0, 1, 1, 1.0, 1, 1, 1.0)], 
      dtype=[('f0', '&lt;i4'), ('f1', '&lt;i4'), ('f2', '&lt;f4'), ('f3', '&lt;i4'), ('f4', '&lt;i4'), ('f5', '&lt;f4'), ('f6', '&lt;i4'), ('f7', '&lt;i4'), ('f8', '&lt;f4')])
</code></pre>

<p>The simplest way to turn this <code>x</code> into an array of floats is with <code>tolist</code> (it's not fastest):</p>

<pre><code>In [256]: x['c']=(20,21,22)
In [257]: x['b']=(10,11,12)
In [258]: x['a']=(1,2,3)

In [263]: print(x)
[((1, 2, 3.0), (10, 11, 12.0), (20, 21, 22.0))]
In [264]: np.array(x.tolist())
Out[264]: 
array([[[  1.,   2.,   3.],
        [ 10.,  11.,  12.],
        [ 20.,  21.,  22.]]])
</code></pre>

python arrays numpy dimensions