Let's say I have some data with timestamps yyyy/mm/dd hh:mm:ss and some error stages (1 meaning an error has occurred). I have the data loaded in a dataframe I call df and want to compute Time\_To\_Next\_Error (measured in seconds) a new column Time\_To\_Error based on the timestamp and Error\_State. 

```
Timestamp            Error_State  Time_To_Next_Error   
2017-05-10 00:10:50      0                10
2017-05-10 00:10:55      0                5 
2017-05-10 00:11:05      1                0
2017-05-10 00:11:10      0                5 
2017-05-10 00:11:15      1                0
2017-05-10 00:11:20      0                15
2017-05-10 00:11:25      0                10
2017-05-10 00:11:30      0                5
2017-05-10 00:11:20      1                0
2017-05-10 00:11:20      0                0 

```

For example, the first observation, there's 15 seconds before the first error occurs at 11:05 after which the count starts over from 0 seconds then the next "window" starts.

Is there a way to define a "window" spanning the next say 5 rows so I can 'look ahead' and check if any of those 5 rows satisfy some condition (like say one of the values is a 1 meaning an Error\_Stage = 1 will happen soon)