title: Pandas resample data to the second, grouping by every ~10 seconds
body: <p>Say I have the following data frame:</p>
  
  <pre><code>&gt;&gt;&gt; df
                         a
  2019-04-05 00:00:00  2.0                
  2019-04-05 00:00:01  1.0
  2019-04-05 00:00:02  NaN
  2019-04-05 00:00:03  NaN
  2019-04-05 00:00:04  NaN
  2019-04-05 00:00:05  NaN
  2019-04-05 00:00:06  NaN
  2019-04-05 00:00:07  NaN
  2019-04-05 00:00:08  3.0
  2019-04-05 00:00:09  4.0
  2019-04-05 00:00:10  NaN
  2019-04-05 00:00:11  NaN
  2019-04-05 00:00:12  NaN
  2019-04-05 00:00:13  NaN
  2019-04-05 00:00:14  NaN
  2019-04-05 00:00:15  NaN
  2019-04-05 00:00:16  NaN
  2019-04-05 00:00:17  NaN
  2019-04-05 00:00:18  NaN
  2019-04-05 00:00:19  NaN
  2019-04-05 00:00:20  4.0
  2019-04-05 00:00:21  5.0
  2019-04-05 00:00:22  NaN
  2019-04-05 00:00:23  NaN
  2019-04-05 00:00:24  NaN
  2019-04-05 00:00:25  NaN
  2019-04-05 00:00:26  6.0
  2019-04-05 00:00:27  NaN
  2019-04-05 00:00:28  4.0
  2019-04-05 00:00:29  NaN
  2019-04-05 00:00:30  NaN
  2019-04-05 00:00:31  NaN
  </code></pre>
  
  <p>I would like to have 1 value per every 7 seconds (assuming there is a value, otherwise just a NaN), so a dataframe that looks like the following:</p>
  
  <pre><code>&gt;&gt;&gt; df
                         a
  2019-04-05 00:00:00  2.0                
  2019-04-05 00:00:01  NaN
  2019-04-05 00:00:02  NaN
  2019-04-05 00:00:03  NaN
  2019-04-05 00:00:04  NaN
  2019-04-05 00:00:05  NaN
  2019-04-05 00:00:06  NaN
  2019-04-05 00:00:07  NaN
  2019-04-05 00:00:08  3.0
  2019-04-05 00:00:09  NaN
  2019-04-05 00:00:10  NaN
  2019-04-05 00:00:11  NaN
  2019-04-05 00:00:12  NaN
  2019-04-05 00:00:13  NaN
  2019-04-05 00:00:14  NaN
  2019-04-05 00:00:15  NaN
  2019-04-05 00:00:16  NaN
  2019-04-05 00:00:17  NaN
  2019-04-05 00:00:18  NaN
  2019-04-05 00:00:19  NaN
  2019-04-05 00:00:20  4.0
  2019-04-05 00:00:21  NaN
  2019-04-05 00:00:22  NaN
  2019-04-05 00:00:23  NaN
  2019-04-05 00:00:24  NaN
  2019-04-05 00:00:25  NaN
  2019-04-05 00:00:26  NaN
  2019-04-05 00:00:27  NaN
  2019-04-05 00:00:28  4.0
  2019-04-05 00:00:29  NaN
  2019-04-05 00:00:30  NaN
  2019-04-05 00:00:31  NaN
  </code></pre>
  
  <p>The 7 second point is arbitrary, I would actually be taking values roughly every minute. Here is what I have tried so far:</p>
  
  <pre><code>df = df.resample('7s').first()
  </code></pre>
  
  <p>but that produces the following dataframe instead:</p>
  
  <pre><code>                       a
  2019-04-05 00:00:00  2.0
  2019-04-05 00:00:07  3.0
  2019-04-05 00:00:14  4.0
  2019-04-05 00:00:21  5.0
  2019-04-05 00:00:28  4.0
  </code></pre>
  
  <p>Note: I am not bothered by the lack of <code>NaN</code>'s between these points, as they are implied. I am just not happy with the timing, as it is forcing a value every 7 seconds, where as I just want to disallow values to be within 7 seconds of each other, not necessitate a value every 7 seconds.</p>
  
  <p>Edith for clarity:</p>
  
  <p>DATAFRAME I DON'T WANT:</p>
  
  <pre><code>                       a
  2019-04-05 00:00:00  2.0
  2019-04-05 00:00:07  3.0
  2019-04-05 00:00:14  4.0
  2019-04-05 00:00:21  5.0
  2019-04-05 00:00:28  4.0
  </code></pre>
  
  <p>DATAFRAME I DO WANT:</p>
  
  <pre><code>&gt;&gt;&gt; df
                         a
  2019-04-05 00:00:00  2.0                
  2019-04-05 00:00:01  NaN
  2019-04-05 00:00:02  NaN
  2019-04-05 00:00:03  NaN
  2019-04-05 00:00:04  NaN
  2019-04-05 00:00:05  NaN
  2019-04-05 00:00:06  NaN
  2019-04-05 00:00:07  NaN
  2019-04-05 00:00:08  3.0
  2019-04-05 00:00:09  NaN
  2019-04-05 00:00:10  NaN
  2019-04-05 00:00:11  NaN
  2019-04-05 00:00:12  NaN
  2019-04-05 00:00:13  NaN
  2019-04-05 00:00:14  NaN
  2019-04-05 00:00:15  NaN
  2019-04-05 00:00:16  NaN
  2019-04-05 00:00:17  NaN
  2019-04-05 00:00:18  NaN
  2019-04-05 00:00:19  NaN
  2019-04-05 00:00:20  4.0
  2019-04-05 00:00:21  NaN
  2019-04-05 00:00:22  NaN
  2019-04-05 00:00:23  NaN
  2019-04-05 00:00:24  NaN
  2019-04-05 00:00:25  NaN
  2019-04-05 00:00:26  NaN
  2019-04-05 00:00:27  NaN
  2019-04-05 00:00:28  4.0
  2019-04-05 00:00:29  NaN
  2019-04-05 00:00:30  NaN
  2019-04-05 00:00:31  NaN
  </code></pre>
  
  <p>OR:</p>
  
  <pre><code>&gt;&gt;&gt; df
                         a
  2019-04-05 00:00:00  2.0
  2019-04-05 00:00:08  3.0
  2019-04-05 00:00:20  4.0
  2019-04-05 00:00:28  4.0
  </code></pre>