title: Interpolate 2D matrix along columns using Python
body: <p>I am trying to interpolate a 2D numpy matrix with the dimensions (5, 3) to a matrix with the dimensions (7, 3) along the axis 1 (columns). Obviously, the wrong approach would be to randomly insert rows anywhere between the original matrix, see the following example:</p>
  
  <pre><code>Source:
   [[0, 1, 1]
    [0, 2, 0]
    [0, 3, 1]
    [0, 4, 0]
    [0, 5, 1]]
  
  Target (terrible interpolation -&gt; not wanted!):
   [[0, 1, 1]
    [0, 1.5, 0.5]
    [0, 2, 0]
    [0, 3, 1]
    [0, 3.5, 0.5]
    [0, 4, 0]
    [0, 5, 1]]
  </code></pre>
  
  <p>The correct approach would be to take every row into account and interpolate between all of them to expand the source matrix to a (7, 3) matrix. I am aware of the scipy.interpolate.interp1d or scipy.interpolate.interp2d methods, but could not get it to work with other Stack Overflow posts or websites. I hope to receive any type of tips or tricks.</p>
  
  <p>Update #1: The expected values should be equally spaced.</p>
  
  <p>Update #2: 
  What I want to do is basically use the separate columns of the original matrix, expand the length of the column to 7 and interpolate between the values of the original column. See the following example:</p>
  
  <pre><code>Source:
   [[0, 1, 1]
    [0, 2, 0]
    [0, 3, 1]
    [0, 4, 0]
    [0, 5, 1]]
  
  Split into 3 separate Columns:
   [0    [1    [1
    0     2     0
    0     3     1
    0     4     0
    0]    5]    1] 
  
  Expand length to 7 and interpolate between them, example for second column:
   [1
    1.66
    2.33
    3
    3.66
    4.33
    5]   
  </code></pre>