title: Merge multiple columns into one column in pyspark using python
body: <p>Input DataFrame:</p>
  
  <pre><code>id,page,location,trlmonth
  1,mobile,chn,08/2018
  2,product,mdu,09/2018
  3,product,mdu,09/2018
  4,mobile,chn,08/2018
  5,book,delhi,10/2018
  7,music,ban,11/2018
  </code></pre>
  
  <p>Output DataFrame:</p>
  
  <pre><code>userdetail,count
  mobile-chn-08/2018,2
  product-mdu-09/2018,2
  book-delhi-10/2018,1
  music-ban-11/2018,1
  </code></pre>
  
  <p>I tried merging single column into one but how to merge multiple columns into one?</p>
  
  <pre><code>from pyspark.sql import functions as F
  
  df2 = (df
    .groupby("id")
    .agg(F.concat_ws("-", F.sort_array(F.collect_list("product"))).alias("products"))
    .groupby("products")
    .agg(F.count("id")).alias("count"))
  </code></pre>