title: Working with structured object arrays in NumPy
body: <p>Say, I have an array of (x, y) points of the following structure:</p>
  
  <pre><code>arr = np.array([([1.     ], [2.     ]),
                  ([1., 93.], [5., 46.]),
                  ([4.     ], [3.     ])],
                 dtype=[('x','O'), ('y', 'O')])
  </code></pre>
  
  <p>i.e. these points are grouped into such innermost arrays. The size of the innermost array might by arbitrary, but it's always same for x and y.</p>
  
  <p>I want to be able to perform two things:</p>
  
  <p>a) Expand the innermost arrays by concatenating their content, so for the above example the result looks like:</p>
  
  <pre><code>np.array([( 1.,  2.),
            ( 1.,  5.),
            (93., 46.),
            ( 4.,  3.)],
           dtype=[('x','f8'), ('y','f8')])
  </code></pre>
  
  <p>b) For each (outermost) entry select element with, say, largest y:</p>
  
  <pre><code>np.array([( 1.,  2.),
            (93., 46.),
            ( 4.,  3.)],
           dtype=[('x','f8'), ('y','f8')])
  </code></pre>
  
  <p>I believe there should be a way of doing this efficiently without using ugly for loops. Would appreciate any help.</p>
  
  <p><strong>UPD ( a and b using ugly loops ):</strong></p>
  
  <p>(arr is the array defined in the beginning of the post)</p>
  
  <p>a)</p>
  
  <pre><code>np.array([(x_, y_) for x, y in arr for x_, y_ in zip(x, y)], dtype=[('x','f8'), ('y','f8')])
  </code></pre>
  
  <p>b)</p>
  
  <pre><code>np.array([(x[np.argmax(np.array(y))], y[np.argmax(np.array(y))]) for x, y in arr],dtype=[('x','f8'), ('y','f8')])
  </code></pre>
  
  <p>Problem is also that in reality I have not just two fields (x and y), but 77 fields of various types (floats, integers, booleans)... So these expressions will grow to many lines.</p>