Let's say that in Pandas I've a dataframe like this:
index    value
1        1
2        0
3        1
4        1
5        0
6        1
I would like to count how many times a specific sequence of values happens, like how many times a 0 occurs right after a 1 (ie. how many times [1, 0] happens, and in the example above it's twice), or how many times [1,0,1] happens (again, twice).
Is there a method to do this without using a mere for cycle?
 
     
    