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, 6, 11]
for start in starts:
dates[start:start + pattern.size] = pattern
> [0 0 1 2 3 0 1 2 3 0 0 1 2 3 0]
I have to do this many (100M+) times on large (10K+) arrays, so I'm looking for a way to do this with broadcasting or another efficient method, avoiding a for loop. pattern will always be a range if that helps.