Align python arrays with missing data
<p>I have some time series data, say:</p>

<pre><code># [ [time] [ data ] ]
a = [[0,1,2,3,4],['a','b','c','d','e']]
b = [[0,3,4]['f','g','h']]
</code></pre>

<p>and I would like an output with some filler value, lets say None for now:</p>

<pre><code>a_new = [[0,1,2,3,4],['a','b','c','d','e']]
b_new = [[0,1,2,3,4],['f',None,None,'g','h']]
</code></pre>

<p>Is there a built in function in python/numpy to do this (or something like this)? Basically I would like to have all of my time vectors of equal size so I can calculate statistics (np.mean) and deal with the missing data accordingly.</p>

<p>Thanks.</p>

<p>How about this? (I'm assuming your definition of <code>b</code> was a typo, and I'm also assuming you know in advance how many entries you want.)</p>

<pre><code>&gt;&gt;&gt; b = [[0,3,4], ['f','g','h']]
&gt;&gt;&gt; b_new = [list(range(5)), [None] * 5]
&gt;&gt;&gt; for index, value in zip(*b): b_new[1][index] = value
&gt;&gt;&gt; b_new
[[0, 1, 2, 3, 4], ['f', None, None, 'g', 'h']]
</code></pre>

python numpy