title: combine text from multiple rows in pyspark
body: <p>I created a PySpark dataframe using the following code</p>
  
  <pre class="lang-python prettyprint-override"><code>testlist = [
               {"category":"A","name":"A1"}, 
               {"category":"A","name":"A2"}, 
               {"category":"B","name":"B1"},
               {"category":"B","name":"B2"}
  ]
  
  spark_df = spark.createDataFrame(testlist)
  </code></pre>
  
  <p>Result:</p>
  
  <pre class="lang-python prettyprint-override"><code>category    name
  A           A1
  A           A2
  B           B1
  B           B2
  </code></pre>
  
  <p>I want to make it appear as follows:</p>
  
  <pre class="lang-python prettyprint-override"><code>category    name
  A           A1, A2
  B           B1, B2
  </code></pre>
  
  <p>I tried the following code which does not work</p>
  
  <pre class="lang-python prettyprint-override"><code>spark_df.groupby('category').agg('name', lambda x:x + ', ')
  </code></pre>
  
  <p>Can anyone help identify what I am doing wrong and the best way to make this happen ?</p>