title: How to group by time and do (and only keep) the mean of the 3 last elements in a Dataframe
body: <p>I have this Python's DataFrame : </p>
  
  <pre><code>temperature time
  10.196833   01-03-2019 00:00:00
  11.084986   01-03-2019 00:00:00
  10.196833   01-03-2019 00:00:00
  10.18458    01-03-2019 00:00:00
  10.397547   01-03-2019 00:00:00
  10.397547   01-03-2019 00:00:00
  9.675623    01-03-2019 01:00:00
  10.382349   01-03-2019 01:00:00
  9.675623    01-03-2019 01:00:00
  9.609171    01-03-2019 01:00:00
  9.901361    01-03-2019 01:00:00
  9.901361    01-03-2019 01:00:00
  8.960459    01-03-2019 02:00:00
  10.513941   01-03-2019 02:00:00
  8.960459    01-03-2019 02:00:00
  10.213129   01-03-2019 02:00:00
  9.446863    01-03-2019 02:00:00
  9.446863    01-03-2019 02:00:00
  </code></pre>
  
  <p>there is one day but 3 hours ( 00:00 to 02:00)
  I would like to only conserve the 3 last lines for each hour and do on it a GroupBy mean to only have the mean of the 3 last elements of each hour : </p>
  
  <pre><code>temperature time
  10.326558       01-03-2019 00:00:00
  9.8039643       01-03-2019 01:00:00
  9.702285        01-03-2019 02:00:00
  </code></pre>
  
  <p>I tried : </p>
  
  <pre><code>dataframe = df.groupby(time).apply(lambda x: x.iloc[[-3]]).mean 
  </code></pre>
  
  <p>But I just got an error</p>