title: Pandas timebased mean
body: <p>I have imported different data from homeassistant to influx db now I have it in a pandas dataframe and I would like to get the the mean() but it should be based on the time in the index.</p>
  <p>I picked a small df to test and it looks like this:</p>
  <pre><code>                                   value
  time                                   
  2021-03-09 07:25:41.989791+00:00    0.0
  2021-03-09 07:26:45.165453+00:00    0.0
  2021-03-09 16:56:04.806150+00:00    1.0
  2021-03-09 18:10:57.762609+00:00    0.0
  2021-03-09 19:45:55.182860+00:00    1.0
  2021-03-09 19:49:27.519186+00:00    0.0
  </code></pre>
  <p>So this is for example just my one of my lights at home. I would like to have the mean over time. So I can see how many % of the time it is turned on. When it says 1 it should be 1 until the next datapoint. In this df the mean should be very low because most of the time the light is turned off. It is only turned on between 16:56:04 to 18:10:57  and 19:45:55 to 19:49:27. So it is turned on approx: 1hour, 19minutes and the total recorded time 12 hours, 23 minutes. So the light was on for approx 10% of the recorded time.</p>
  <p>There are another two problems:</p>
  <ol>
  <li><p>I have sensors that have different values than 1 and 0 (for example temperature)</p>
  <p>2.the day will change.</p>
  </li>
  </ol>
  <p>I don't really know how to get started does anyone have a idea ?</p>