It's easy to resample an array like
a = numpy.array([1,2,3,4,5,6,7,8,9,10])
with an integer resampling factor. For instance, with a factor 2 :
b = a[::2] # [1 3 5 7 9]
But with a non-integer resampling factor, it doesn't work so easily :
c = a[::1.5] # [1 2 3 4 5 6 7 8 9 10] => not what is needed...
It should be (with linear interpolation):
[1 2.5 4 5.5 7 8.5 10]
or (by taking the nearest neighbour in the array)
[1 3 4 6 7 9 10]
How to resample a numpy array with a non-integer resampling factor?
Example of application: audio signal resampling / repitching



scipy.interpolate.interp1dor one of the other interpolation routines in scipy::2way of indexing.numpyarrays (and Python lists) are not primarily seen as samples (though their values may represent samples of something else).numpyarray for audio data contained in a .WAV files. Doing this on this array is called "resampling" in audio / or "repitching", it depends on how we use it.