I have a sequence of numbers that I would like to insert into a larger array at irregular intervals:
dates = np.zeros(15) pattern = np.arange(3) + 1 starts = [2,
Construct a 2D selector array to select the indices of dates you want to modify with numpy.add.outer, then perform a broadcasted assignment of pattern into the selected indices:
dates
numpy.add.outer
pattern
dates[numpy.add.outer(starts, numpy.arange(len(pattern)))] = pattern