This line of code
is looping over all rows except for the last one, so it never "sees" the last row. Therefore, if it is more than 2 hours away from the prior row, it gets missed entirely.
You need to add logic to handle that case.
Personally, I think it might make more sense to set
prior to the loop. Then loop over
and if the gap is greater than 2 hours to the prior value, plot accumulated values and start over. If the gap is less than 2 hours, just accumulate.
In essence, I am saying it might be simpler to look back, than look ahead. I would also recommend commenting your code to explain the logic.