lundi 19 juillet 2021

Python finding reoccuring values in list (backtesting)

and thanks in advance.

my problem is the following: I wanna analyse a dataframe (list) consisting of only e.g. "x" and "y". only if "x" is given in three consecutive indizes I want to get a statement that gives me the index of the third time when value = x, not the fourth or n time and then it should repeat this loop for the whole list, giving me the indizes for all the times when "x" occured in three consecutive indizes

>  0 = y  
1 = x  
2 = y  
3 = x  
4 = x  
5 = x  
6 = x  
7 = y  
8 = x  
9 = x
10 = x

and so on

desired result

print (i)

     - 5 , 10

Aucun commentaire:

Enregistrer un commentaire