title: counting rows of a dataframe with condition in spark
body: <p>I am trying this:</p>
  
  <pre><code>df=dfFromJson:
  {"class":"name 1","stream":"science"}
  {"class":"name 1","stream":"arts"}
  {"class":"name 1","stream":"science"}
  {"class":"name 1","stream":"law"}
  {"class":"name 1","stream":"law"}
  {"class":"name 2","stream":"science"}
  {"class":"name 2","stream":"arts"}
  {"class":"name 2","stream":"law"}
  {"class":"name 2","stream":"science"}
  {"class":"name 2","stream":"arts"}
  {"class":"name 2","stream":"law"}
  
  
  df.groupBy("class").agg(count(col("stream")==="science") as "stream_science", count(col("stream")==="arts") as "stream_arts", count(col("stream")==="law") as "stream_law")
  </code></pre>
  
  <p>This is not giving expected output, how can I achieve it in fastest way?</p>