title: Resampling (upsampling, interpolating) a series of numbers
body: <p>I have a comma separated series of integer values that I'd like to resample so that I have twice as many, where a new value is added half way between each of the existing values. For example, if this is my source:</p>
  
  <pre><code>1,5,11,9,13,21
  </code></pre>
  
  <p>the result would be:</p>
  
  <pre><code>1,3,5,8,11,10,9,11,13,17,21
  </code></pre>
  
  <p>In case that's not clear, I'm trying to add a number between each of the values in my source series, like this:</p>
  
  <pre><code>1   5   11    9    13    21
  1 3 5 8 11 10 9 11 13 17 21
  </code></pre>
  
  <p>I've searched quite a bit and it seems that something like scipy.signal.resample or panda should work, but I'm completely new at this and I haven't been able to get it working. For example, here's one of my attempts with scipy:</p>
  
  <pre><code>import numpy as np
  from scipy import signal
  InputFileName = "sample.raw"
  DATA250  = np.loadtxt(InputFileName, delimiter=',', dtype=int);
  print(DATA250)
  DATA500 = signal.resample(DATA250, 11)
  print(DATA500)
  </code></pre>
  
  <p>Which outputs:</p>
  
  <pre><code>[ 1  5 11  9 13 21]
  [ 1.         -0.28829461  6.12324489 10.43251996 10.9108191   9.84503237
    8.40293529 10.7641676  18.44182898 21.68506897 12.68267746]
  </code></pre>
  
  <p>Obviously I'm using signal.resample incorrectly. Is there a way I can do this with signal.resample or panda? Should I be using some other method? </p>
  
  <p>Also, in my example all of source numbers have an integer half way in between. In my actual data, that won't be the case. So if two of the number are 10,15, the new number would be 12.5. However I'd like to have all of the resulting numbers be integers. So the new number that gets inserted would need to either be 12 or 13 (it doesn't matter to me which it is).</p>
  
  <p>Note that once I get this working, the source file will actually be a comma separated list of 2,000 numbers and the output should be 4,000 numbers (or technically 3,999 since there won't be one added to the end). Also, this is going to be used to process something similar to an ECG recording- currently the ECG is sampled at 250 Hz for 8 seconds, which is then passed to a separate process to analyze the recording. However that separate process needs the recording to be sampled at 500 Hz. So the workflow will be that I'll take a 250 Hz recording every 8 seconds and upsample it to 500 Hz, then pass the resulting output to the analysis process.</p>
  
  <p>Thanks for any guidance you can provide.</p>