title: Create new pyspark DataFrame column by concatenating values of another column based on a conditional
body: <p>I have a data frame in <code>pyspark</code> like below</p>
  
  <pre class="lang-python prettyprint-override"><code>df.show()
  
  +-------+--------------------+--------------------+
  | Dev_No|               model|              Tested|
  +-------+--------------------+--------------------+
  |BTA16C5|          Windows PC|                   N|
  |BTA16C5|                 SRL|                   N|
  |BTA16C5|     Hewlett Packard|                   N|
  |CTA16C5|     Android Devices|                   Y|
  |CTA16C5|     Hewlett Packard|                   N|
  |4MY16A5|               Other|                   N|
  |4MY16A5|               Other|                   N|
  |4MY16A5|              Tablet|                   Y|
  |4MY16A5|               Other|                   N|
  |4MY16A5|           Cable STB|                   Y|
  |4MY16A5|               Other|                   N|
  |4MY16A5|          Windows PC|                   Y|
  |4MY16A5|          Windows PC|                   Y|
  |4MY16A5|         Smart Watch|                   Y|
  +-------+--------------------+--------------------+
  </code></pre>
  
  <p>Now using the above data frame I want to create the below data frame with a <code>newcolumn</code> called <code>Tested_devices</code> and populate the column with values where for each <code>Dev_No</code> select <code>model</code> where <code>Tested</code> is <code>Y</code> and populate all the values as comma separated.</p>
  
  <pre class="lang-python prettyprint-override"><code>df1.show()
  
  +-------+--------------------+--------------------+------------------------------------------------------+
  | Dev_No|               model|              Tested|                                        Tested_devices|
  +-------+--------------------+--------------------+------------------------------------------------------+
  |BTA16C5|          Windows PC|                   N|                                                      |
  |BTA16C5|                 SRL|                   N|                                                      |  
  |BTA16C5|     Hewlett Packard|                   N|                                                      |
  |CTA16C5|     Android Devices|                   Y|                                       Android Devices|
  |CTA16C5|     Hewlett Packard|                   N|                                                      |      
  |4MY16A5|               Other|                   N|                                                      |
  |4MY16A5|               Other|                   N|                                                      |
  |4MY16A5|              Tablet|                   Y| Tablet, Cable STB,Windows PC, Windows PC, Smart Watch| 
  |4MY16A5|               Other|                   N|                                                      |
  |4MY16A5|           Cable STB|                   Y| Tablet, Cable STB,Windows PC, Windows PC, Smart Watch|
  |4MY16A5|               Other|                   N|                                                      |
  |4MY16A5|          Windows PC|                   Y| Tablet, Cable STB,Windows PC, Windows PC, Smart Watch|
  |4MY16A5|          Windows PC|                   Y| Tablet, Cable STB,Windows PC, Windows PC, Smart Watch|
  |4MY16A5|         Smart Watch|                   Y| Tablet, Cable STB,Windows PC, Windows PC, Smart Watch|
  +-------+--------------------+--------------------+------------------------------------------------------+
  </code></pre>
  
  <p>I tried something like below to select <code>Dev_No</code> and <code>model</code> where <code>Tested</code> is <code>Y</code> </p>
  
  <pre class="lang-python prettyprint-override"><code>a = df.select("Dev_No", "model"), when(df.Tested == 'Y')
  </code></pre>
  
  <p>I am unable to get the result. It gave me below error</p>
  
  <pre class="lang-python prettyprint-override"><code>TypeError: when() takes exactly 2 arguments (1 given)
  </code></pre>
  
  <p>How can I achieve what I want</p>