title: Create an ndarray from arrays of different lengths
body: <p>How do you elegantly create a NumPy <code>ndarray</code> from (1D-)arrays of different lengths, padding the remainder?</p>
  
  <p>The arrays are always 1D, they have different lengths (maximum length varied between 20 and 100).</p>
  
  <p>Say there is </p>
  
  <pre><code>a = range(40)
  b = range(30)
  </code></pre>
  
  <p>The resultant <code>ndarray</code> should be</p>
  
  <pre><code>X = [[0,1,2,3,...,39,40],
       [0,1,2,...29,30,0,0,...,0]]
  </code></pre>
  
  <h3>Hacky solution</h3>
  
  <p>Creating an intermediary</p>
  
  <pre><code>I = [a,b]
  </code></pre>
  
  <p>and padding to a <code>maximum</code> via</p>
  
  <pre><code>I[1].extend([0] * (maximum - len(I[1])))
  </code></pre>
  
  <p>which can then be converted via</p>
  
  <pre><code>X = np.array(I)
  </code></pre>
  
  <p>works but is there nothing built-in / available via PyPI / more pythonic?</p>