title: Minima values of nested array (possibly partially empty)
body: <p>I'll like to compute the minimums of some nested 2D arrays on axis 1.
  My problem is the following: The arrays might have 1 (or more) empty axis, which if I try to apply <code>np.min</code> on it will throw some errors.</p>
  
  <p>Note that I'll like the code to return <code>-1</code> if the axis is empty (By initialisation my array can't have negative values).
  For example, I might want to have the minima values of <code>m</code> defined as follow:</p>
  
  <pre><code>import numpy as np
  m = np.array([np.array([1,2]),np.array([3,4,5,6]),np.array([]),np.array([7,8,9])])
  # Expected output in this case: [1,3,-1,7]
  </code></pre>
  
  <p>I first try:</p>
  
  <pre><code>_min = np.min(m, axis=1)
  </code></pre>
  
  <p>Which gives the following error:</p>
  
  <blockquote>
    <p>ValueError: 'axis' entry is out of bounds</p>
  </blockquote>
  
  <p>So, since the error comes from the fact that the array in nested (it has shape <code>(4,)</code>, I tried:</p>
  
  <pre><code>_min = [np.min(x) for x in m]
  </code></pre>
  
  <p>Which throw:</p>
  
  <blockquote>
    <p>ValueError: zero-size array to reduction operation minimum which has no identity</p>
  </blockquote>
  
  <p>Here the error comes from the fact that <code>m[2] = []</code> which is zero-size array.</p>
  
  <p>All I come up with is this inefficient and ugly solution:</p>
  
  <pre><code>_min = []
  for x in m:
      if len(x) &gt; 0:
          _min.append(np.min(x))
      else:
          _min.append(-1)
  # [1, 3, -1, 7]
  </code></pre>
  
  <p>Is there a simple way to achieve that with a more pythonic way?</p>
  
  <hr>
  
  <p><strong>edit</strong>
  The pythonic solution proposed by @Divakar doesn't work when the empty axis is the last element (<code>m[-1]</code>):</p>
  
  <pre><code>m = np.array([np.array([0.53, 0.56]), np.array([0.33, 0.31, 0.27, 0.48, 0.36, 0.35, 0.27, 0.24]), np.array([])])
  </code></pre>
  
  <p>Error given:</p>
  
  <blockquote>
    <p>IndexError: index 10 out-of-bounds in minimum.reduceat [0, 10)</p>
  </blockquote>