title: Is it possible to groupBy a Spark's dataframe when not all values are present in column?
body: <p>For example, if I have the following dataframe</p>
  
  <pre><code>val tempDF=Seq(("a",2),("b",1),("a",3)).toDF("letter","value")
  
  scala&gt; tempDF.show()
  +------+-----+
  |letter|value|
  +------+-----+
  |     a|    2|
  |     b|    1|
  |     a|    3|
  +------+-----+
  </code></pre>
  
  <p>and I want to perform a <code>groupBy</code> operation on the column <code>letter</code> but knowing that there could be another letter <code>c</code> not present in the column <code>letter</code>. Normally I would have</p>
  
  <pre><code>tempDF.groupBy("letter").sum()
  
  scala&gt; tempDF.groupBy("letter").sum().show()
  +------+----------+                                                               
  |letter|sum(value)|
  +------+----------+
  |     a|         5|
  |     b|         1|
  +------+----------+
  </code></pre>
  
  <p>but I would like something like this:</p>
  
  <pre><code>+------+----------+                                                             
  |letter|sum(value)|
  +------+----------+
  |     a|         5|
  |     b|         1|
  |     c|         0|
  +------+----------+
  </code></pre>
  
  <p>Is it possible to do this without somehow adding the letter <code>c</code> to the dataframe? What I mean is that I could have many dataframes in a list but I don't know which letters are missing (if any) for each dataframe, instead I do know the whole list of letters that should appear for each one.</p>