How to calculate running time from status and time using python
<p>I have a circulation pump that I check wither it's on or off on and this is not by any fixed interval what so ever. For a single day that could give me a dataset looking like this where 'value' represents the pump being on or off.</p>

<pre><code>data=(
 {'value': 0, 'time': datetime.datetime(2011, 1, 18, 7, 58, 25)},
 {'value': 1, 'time': datetime.datetime(2011, 1, 18, 8, 0, 3)},
 {'value': 0, 'time': datetime.datetime(2011, 1, 18, 8, 32, 10)},
 {'value': 0, 'time': datetime.datetime(2011, 1, 18, 9, 22, 7)},
 {'value': 1, 'time': datetime.datetime(2011, 1, 18, 9, 30, 58)},
 {'value': 1, 'time': datetime.datetime(2011, 1, 18, 12, 2, 23)},
 {'value': 0, 'time': datetime.datetime(2011, 1, 18, 15, 43, 11)},
 {'value': 1, 'time': datetime.datetime(2011, 1, 18, 20, 14, 55)})
</code></pre>

<p>The format is not that important and can be changed.</p>

<p>What I do want to know is how to calculate how many minutes ( or timespan or whatever) the <code>'value'</code> has been 0 or 1 (or ON or OFF)?</p>

<p>This is just a small sample of the data, it stretches over several years so there could be a lot.
I have been using numpy/mathplotlib for plotting some graphs and there might be something in numpy to do this but I'm not good enough at it.</p>

<p><strong>Edit</strong></p>

<p>What I would like to see as an output to this would be a sum of the time in the different states. Something like...</p>

<pre><code>0 04:42:13  
1 07:34:17
</code></pre>
