I need to place all the elements from my first list to knth positions of the second list. Where k = 0,1,2...
and n is a single number. Currently I am doing this (using numpy)
#create numpy array
positionList = np.array([])
positions = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
epochs = np.array([10, 11, 12])
for pos,epoch in zip(positions,epochs):
position = np.insert(pos,0,epoch)
if len(positionList) > 0:
positionList = np.concatenate((positionList,position))
else:
positionList = position
positionList = np.around(positionList,1).tolist()
#expected output [10, 1, 2, 3, 11, 4, 5, 6, 12, 7, 8, 9]
Where positions is 2D. I am trying to find the most efficient possible (time and space) way to do this with numpy.
Note: The above code does work. I just want to make it efficient.