Python interpolation data list of lists
<p>I have got this data:</p>

<pre><code>X = [[10, 6, 0], [8, 6, 0], [4, 3, 0]]
Y = [[29, 28, 27], [26, 25, 24], [23, 22, 21]]
</code></pre>

<p>I need to interpolate between values in X. for instance:</p>

<pre><code>D = np.linspace(10,0,num = 6)

Out:[  0.   2.   4.   6.   8.  10.]
</code></pre>

<p>So result should be like:</p>

<pre><code> "D"     "Y[0]"      "Y[1]"   "Y[2]"
  0        27          24        21
  2        ?           ?         ?
  4        ?           ?         23
  6        28          25        ?
  8        ?           26        ?
  10       29          ?         ?
</code></pre>

<p>I know there is <code>np.interp()</code> I tried and it works only for one dimensional list:</p>

<pre><code>z =[0,5,10]
v= [29,28,27]
x = np.linspace(10,0,num = 4)
d=np.interp(x, z, v)
print (d)
</code></pre>

<p>But If I have list of lists it doen't work.</p>

<p>Use <code>zip</code>. Also, it looks like you want to reverse the sublists. Maybe something like:</p>

<pre><code>points = np.linspace(0,10,num = 6)

cols = (points,) + tuple(np.interp(points,x[::-1],y[::-1]) for x,y in zip(X,Y))

np.stack(cols,axis=1)
</code></pre>

<p>which has output:</p>

<pre><code>array([[  0.        ,  27.        ,  24.        ,  21.        ],
       [  2.        ,  27.33333333,  24.33333333,  21.66666667],
       [  4.        ,  27.66666667,  24.66666667,  23.        ],
       [  6.        ,  28.        ,  25.        ,  23.        ],
       [  8.        ,  28.5       ,  26.        ,  23.        ],
       [ 10.        ,  29.        ,  26.        ,  23.        ]])
</code></pre>

<p>This shows interpolation. It seems like you might want to use extrapolation in some entries in some columns.</p>

python interpolation