title: Pyspark conditional running window
body: <p>I have a dataframe which looks like this</p>
  <pre><code>starttime           |  endtime            |
  2022-01-01 03:25:53 | 2022-01-01 03:25:52 |
  2022-01-01 03:25:53 | 2022-01-01 03:25:52 |
  2022-01-01 03:25:53 | 2022-01-01 03:25:52 |
  2022-01-01 03:25:55 | 2022-01-01 03:25:54 |
  2022-01-01 03:25:57 | 2022-01-01 03:25:57 |
  </code></pre>
  <p>I want to add another column which is a rownumber/rank which increments if difference between starttime and endtime is greater than 1 second.</p>
  <p>So, the expected result should look something like this</p>
  <pre><code>starttime           |  endtime            | group |
  2022-01-01 03:25:53 | 2022-01-01 03:25:52 | 1     |
  2022-01-01 03:25:53 | 2022-01-01 03:25:52 | 1     |
  2022-01-01 03:25:53 | 2022-01-01 03:25:52 | 1     |
  2022-01-01 03:25:55 | 2022-01-01 03:25:54 | 2     |
  2022-01-01 03:25:57 | 2022-01-01 03:25:57 | 3     |
  </code></pre>