Convert Python sequence to NumPy array, filling missing values
<p>The implicit conversion of a Python sequence of <em>variable-length</em> lists into a NumPy array cause the array to be of type <em>object</em>.</p>

<pre><code>v = [[1], [1, 2]]
np.array(v)
&gt;&gt;&gt; array([[1], [1, 2]], dtype=object)
</code></pre>

<p>Trying to force another type will cause an exception:</p>

<pre><code>np.array(v, dtype=np.int32)
ValueError: setting an array element with a sequence.
</code></pre>

<p>What is the most efficient way to get a dense NumPy array of type int32, by filling the "missing" values with a given placeholder?</p>

<p>From my sample sequence <code>v</code>, I would like to get something like this, if 0 is the placeholder</p>

<pre><code>array([[1, 0], [1, 2]], dtype=int32)
</code></pre>