title: Spark Scala: group by multiple columns with aggregation logic
body: <p>Given the following DataFrame:</p>
  
  <pre><code>+----+--------+--------+-----+------+------+------+
  |name|platform|group_id|width|height|     x|     y|
  +----+--------+--------+-----+-------------+------+
  |   a|  plat_a|       0|500.0|1000.0|250.41|500.01|
  |   a|  plat_a|       0|250.0| 500.0|125.75| 250.7|
  |   a|  plat_a|       0|300.0| 800.0| 120.0| 111.7|
  |   b|  plat_b|       0|500.0|1000.0| 250.5|500.67|
  |   b|  plat_b|       1|400.0| 800.0|100.67|200.67|
  |   b|  plat_b|       1|800.0|1600.0|201.07|401.07|
  +----+--------+--------+-----+------+------+------+
  </code></pre>
  
  <p>I would like to group by name, platform, group_id and count by the following columns logic:  </p>
  
  <pre><code>//normalizing value to percent with 2 digit precision
  new_x = Math.round(x / width * 100.0) / 100.0
  new_y = Math.round(y / height * 100.0) / 100.0
  </code></pre>
  
  <p>So the output DataFrame would be:</p>
  
  <pre><code>+----+--------+--------+------+------+-----+
  |name|platform|group_id| new_x| new_y|count|
  +----+--------+---------------+------+-----+
  |   a|  plat_a|       0|   0.5|   0.5|    2|
  |   a|  plat_a|       0|   0.4|  0.13|    1|
  |   b|  plat_b|       0|   0.5|   0.5|    1|
  |   b|  plat_b|       1|  0.25|  0.25|    2|
  +----+--------+--------+------+------+-----+
  </code></pre>
  
  <p>How should I approach this problem?</p>