title: resample 5 minutes only by past
body: <h1>Problem</h1>
  <p>How to create column that resamples 5 minutes in pandas but only till current certain row, so either last 5 minutes from current observation, or 5 minutes interval but if I am at minute 3 to resample last 5 or last 3, point being not to resample by future.
  DataFrame is ordered by datetime</p>
  <p>for example first rows can be disregarded since 5 mins did not accumulate yet:</p>
  <h1>Desired output</h1>
  <p><a href="https://i.stack.imgur.com/Tkibp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tkibp.png" alt="enter image description here" /></a></p>
  <pre><code>
  datetime    result  mean
  3/1/2022 0:04   1   
  3/1/2022 0:05   0   
  3/1/2022 0:06   0   
  3/1/2022 0:06   1   
  3/1/2022 0:07   1   
  3/1/2022 0:08   1   
  3/1/2022 0:10   1   0.666666667
  3/1/2022 0:11   1   0.833333333
  3/1/2022 0:12   0   0.8
  3/1/2022 0:13   0   0.666666667
  3/1/2022 0:14   0   0.4
  3/1/2022 0:17   0   0
  3/1/2022 0:18   1   0.25
  3/1/2022 0:19   1   0.5
  3/1/2022 0:20   1   0.75
  3/1/2022 0:21   1   0.8
  3/1/2022 0:22   1   0.833333333
  3/1/2022 0:23   1   1
  </code></pre>