title: How to calculate time spent in a sub-group in Time-Series data?
body: <p>I have Time-Series data in a pandas dataframe with time in range 0 to 4000 and the values are arbitrary between 500-900.</p>
  <p>It looks like this:</p>
  <p><img src="https://i.stack.imgur.com/74uUr.png" alt="It looks like this" /></p>
  <p>I want to calculate how much time is spent in the different sub-groups of y-axis like 500-550, 550-600 ... 850-900.</p>
  <p>For example:</p>
  <p>Small part of the same graph:</p>
  <p><img src="https://i.stack.imgur.com/zpJt4.png" alt="Small part of the same graph" /></p>
  <p>In this part of the graph, for 700-800 y-axis values, it spent 3850-3800= 50s, 600-700 values it spent 4100-3850=250s and so on.</p>