title: get a Spark Dataframe histogram after groupBy count
body: <p>I have a large Spark DataFrame and after a groupBy-count operation, a summary of my dataset can be obtained as follow:</p>
  
  <pre><code>myResultDF
  
  +---+---+-----+----------+
  |SEX|AGE|count|    result|
  +---+---+-----+----------+
  |  1|  4| 1420| 0.2665724|
  |  2|  8|  801|0.32442601|
  |  1|  1| 2123| 0.2259348|
  |  2|  3| 1329| 0.2732647|
  |  2|  2| 1224|0.28158098|
  |  1|  2| 1295|0.27588340|
  |  2|  6| 1063| 0.2958312|
  +---+---+-----+----------+
  </code></pre>
  
  <p>Now, I would like to generate a histogram of my results between 0 and 1, while taking into account the <code>count</code> column.</p>
  
  <p>So far, following <a href="http://blog.madhukaraphatak.com/statistical-data-exploration-spark-part-2/" rel="nofollow noreferrer">this link</a> I can create a histogram of my result without considering the <code>count</code> column:</p>
  
  <pre><code>val histogramX = (0 to 10 toArray).map({case (x: Int) =&gt; x.toDouble / 10})
  
  val histogramY = myResultDF
        .select("result")
        .map(value =&gt; value.getDouble(0))
        .rdd.histogram(histogramX, true)
  </code></pre>
  
  <p>This code only gives me a histogram of six occurrences between 0.2 and 0.3, and one occurrence between 0.3 and 0.4.</p>
  
  <p>But what I want is (1420+2123+1329+1224+1295+1063) occurrences between 0.2 and 0.3, and 801 occurences between 0.3 and 0.4.</p>
  
  <p>Any suggestions for this calculation would be much appreciated :)</p>