Python : Processing sub List based on a condition
NumPy is optimized for numerical calculation, so you should use it. But in this case I would use Pandas instead, since it "preserve the index" when you do calculations and it's built on top of NumPy, so you can take advantage of NumPy's optimization.
To apply the functions you could use the conditional selection on your DataFrame, and then assign the results to a new column, and here is where you take the advantage of the index preservation in Pandas, since you don't want to lose the information about in which distance you're applying the functions.
I have a set of points(x,y), could be setup as an Array or a List.
I wish to calculate the distance between subsequent points.
I then need to do some calculations on the between distances to set a threshold value T.
I then wish to process the Array/List of points such that when a between distance exceeds the threshold T, I call a function_A passing all the preceding points and then function_B passing the current and preceding point, before continuing test points against the threshold value.
i.e. If I have between distance list [1, 1.5, 2, 1.7, 7, 2, 3, 8, 4 ]
Threshold calculated as 7.
I wish to call function_A with the points that correspond to [1, 1.5, 2, 1.7] function_B with the points that correspond to 1.7 and 7, then next time Threshold is exceeded i.e 8 call function_A with points corresponding to [2,3] etc.
Need to process several hundred points as above, so should I use numpty?