I have a python code where I need to count the number of ids in a given range of timestamps as :
id_number= for i in range(numbers): indices=numpy.argwhere((a[i] >= dataset[:,0]) & (a[i] <= dataset[:,1])) id_number.append(len(set(dataset[indices[:,0],2])))
numbers is an integer indicating the length of the array (
a) that has timestamps.
dataset[:,1] has starting and ending ranges for timestamps and I have to compute the unique ids for a timestamp from the dataset.
The issue is: it is taking approx 0.7 seconds for one loop iteration making it run for about 5 days based on the length of a.
Is there a way to optimize this code, for it to complete early.