My question is how to efficiently expand an array, by copying itself many times. I am trying to expand my survey samples to the full size dataset, by copying every sample N times. N is the influence factor that signed to the sample. So I wrote two loops to do this task (script pasted below). It works, but is slow. My sample size is 20,000, and try to expand it into 3 million full size.. is there any function I can try? Thank you for your help!
----My script----
lines = np.asarray(person.read().split('\n'))
df_array = np.asarray(lines[0].split(' '))
for j in range(1,len(lines)-1):
subarray = np.asarray(lines[j].split(' '))
factor = int(round(float(subarray[-1]),0))
for i in range(1,factor):
df_array = np.vstack((df_array, subarray))
print len(df_array)