I have a big dataframe with trading data, and I am trying to group the data in small clusters. I have a column called Ticks, with either 1,-1 or 0. I want to do a conditional statement like "if tick is 1 or -1, count 1, if it is 0 don't add anything but still keep that trade in memory. Once we reach 1000 (so 1000 occurences with either 1 or -1, and all the lines with "0" in between), create a new array and continue this operation.
I read about numpy and how it is much faster than traditional python loops, but I'm not sure how to do this without loops. I read quite a few similar stackoverflow issues and explanations about vectorization etc... But I have to admit I did not really understand them, maybe because my math level is too low or I did not understand the code used in the example. But I couldn't find an example with data from pandas converted to numpy. example of my dataframe