Look at the below code, in which I have two arrays:
t1 = np.array([0,13,22,...,99994])
t2 = np.array([4,14,25,...,99998])
I'm searching for an efficient way to create an output like this:
np.array([0,1,2,3,4,13,14,22,23,24,25,...,99994,99995,99996,99997,99998])
One way to do this is:
np.array([i for a, b in zip(t1, t2) for i in range(a, b + 1)])
But, this solution is moderate and I am sure that it can, in any case, be inconceivably improved by altogether replacing the zip and list comprehension combo for certain functions completely in Numpy, it is only that I don't have the foggiest idea how. Can you folks show me the most proficient approach to do it?
The below code helps to generate two arrays:
import numpy as np
m =10000
Z = np.arange(0,10*m,10)
t1 = np.random.randint(5, size =m ) + Z
t2 =np.random.randint(5,size = m) + 5 + Z