Issue
I have two arrays that I want to merge to a new one but I need to insert the indices in specific places
array1 = np.arange(95,320,4)
array2 = np.arange(0,360,2)
For example.. array1[0] = 95
, but I want this value to be in a new array between array2[47]
which equals 94 and array2[48]
that equals 96, and so on with the rest of the values inside array1.
Is this possible?
Solution
I think that you’re looking for numpy.insert
array1 = np.arange(95,320,4)
array2 = np.arange(0,360,2)
for i, value in enumerate(array1):
index = i+48+i*2
array2 = np.insert(array2, index, array1[i])
Answered By – remarcoble
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0