title: Spark: count percentage percentages of a column values
body: <p>I am trying to improve my Spark Scala skills and I have this case which I cannot find a way to manipulate so please advise!</p>
  
  <p>I have original data as it shown in the figure bellow:</p>
  
  <p><a href="https://i.stack.imgur.com/qq8h4.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qq8h4.jpg" alt="enter image description here"></a></p>
  
  <p>I want to calculate the percentage of every result of the count column  . E.g. the last error value is 64  how much is 64 as a percentage out of the all column values. Please note that I am reading the original data as Dataframes using sqlContext:
  Here is my code: </p>
  
  <pre><code>    val df1 = df.groupBy(" Code")
  .agg(sum("count").alias("sum"), mean("count")
  .multiply(100)
  .cast("integer").alias("percentag‌​e")) 
  </code></pre>
  
  <p>I want results similar to this:</p>
  
  <p><a href="https://i.stack.imgur.com/4tC0a.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/4tC0a.jpg" alt="enter image description here"></a></p>
  
  <p>Thanks in advance!</p>