title: Split time-series dataframe
body: <p>I have a dataframe where I have different parameters as columns and a timestamp for each row of parameters.</p>
  
  <p>What I want to do is to split the dataframe into windows, where column values from each row get all appended into a single row. This will enable me to run clustering using these as features.</p>
  
  <p>For example, I want to transform dataframe like this (window size 3):</p>
  
  <pre><code>2017-01-01 00:00:01, a1, b1, c1
  2017-01-01 00:00:02, a2, b2, c2
  2017-01-01 00:00:03, a3, b3, c3
  2017-01-01 00:00:04, a4, b4, c4
  2017-01-01 00:00:05, a5, b5, c5
  2017-01-01 00:00:06, a6, b6, c6
  2017-01-01 00:00:07, a7, b7, c7
  </code></pre>
  
  <p>Into something like this:</p>
  
  <pre><code>2017-01-01 00:00:01, 2017-01-01 00:00:03, a1, a2, a3, b1, b2, b3, c1, c2, c3
  2017-01-01 00:00:04, 2017-01-01 00:00:06, a4, a5, a6, b4, b5, b6, c4, c5, c6
  </code></pre>
  
  <p>I need to preserve information which time interval belongs to which cluster, after clustering, so that is why I also need to keep the time ranges. The last instant in the example was excluded as there's not enough measurements to create another window.</p>
  
  <p>How can I do this using Spark?</p>