title: Merging multiple rows in a spark dataframe into a single row
body: <p>I have a data frame with 2 columns: timestamp, value
  timestamp is a time since the epoch and value is a float value.
  I want to merge rows to average values by min.
  That means that I want to take all rows where timestamp is from the same round minute (60 seconds intervals since the epoch) and merge them into a single row, where the value column will be the mean of all the values.</p>
  
  <p>To give an example, lets assume that my dataframe looks like this:</p>
  
  <pre><code>timestamp      value
  ---------      -----
  1441637160      10.0
  1441637170      20.0
  1441637180      30.0
  1441637210      40.0
  1441637220      10.0
  1441637230      0.0
  </code></pre>
  
  <p>The first 4 rows are part of the same min (1441637160 % 60 == 0, 1441637160 + 60 == 1441637220)
  The last 2 rows are part of another min.
  I would like to merge all rows of the same min. to get a result that looks like:</p>
  
  <pre><code>timestamp      value
  ---------      -----
  1441637160      25.0  (since (10+20+30+40)/4 = 25)
  1441637220      5.0   (since (10+0)/2 = 5)
  </code></pre>
  
  <p>What's the best way to do that?</p>