Upsampling in Python I'm trying to perform upsampling in Python. Given the signal 's' and factor of upsampling N, I wrote the following code:

&gt; y = np.zeros(N*len(s))
&gt; for i in range(0, N*len(s), N):
&gt;     for j in range(len(s)):
&gt;             y[i] = s[j]
&gt; return y


However, when I have a signal with first value '1' and factor of upsamling 3, my output of the function is like [1, 0, 0, 1, 0, 0] etc, no matter what the rest of the signal looks like. Is there a way to make this code work properly?
I think you are trying to do this:

y = np.zeros(N*len(s))
for i in range(0, len(s)):
    y[i*N] = s[i]

return y


There are other ways in python that avoid explicit loops, for example:

y = [0] * (N * len(s))
y[::N] = s