title: Populate new columns when list values match substring of column values in Pyspark dataframe
body: <p>I have a data frame in <code>Pyspark</code> like below</p>
  
  <pre><code>df.show()
  
  +---+----------------------+
  | id|                   con|
  +---+----------------------+
  |  3|           mac,mac pro|
  |  1|        iphone5,iphone|
  |  1| android,android phone|
  |  1|    windows,windows pc|
  |  1| spy camera,spy camera|
  |  2|               camera,|
  |  3|             cctv,cctv|
  |  2|   apple iphone,iphone|
  |  3|           ,spy camera|
  +---+----------------------+
  </code></pre>
  
  <p>I want to create new columns based on certain <code>lists</code>. Lists are below</p>
  
  <pre><code>phone_list = ['iphone', 'android', 'nokia']
  pc_list = ['windows', 'mac']
  </code></pre>
  
  <p><code>Condition:</code></p>
  
  <pre><code>if a element in a list matches a string/substring in a column then flag the column to the value of that particular list
  </code></pre>
  
  <p>Basically what I want is in <code>phone_list</code> I have element <code>iphone</code> so that should match <code>id</code> <code>1</code> where <code>con</code> is <code>iphone5, iphone</code> and flag as <code>phones</code> and so on.</p>
  
  <p><code>Expected result</code></p>
  
  <pre><code>+---+----------------------+------+----+
  | id|                   con|   cat| abc|
  +---+----------------------+------+----+
  |  3|           mac,mac pro|  null|  pc|
  |  1|        iphone5,iphone|phones|null|
  |  1| android,android phone|phones|null|
  |  1|    windows,windows pc|  null|  pc|
  |  1| spy camera,spy camera|  null|null|
  |  2|               camera,|  null|null|
  |  3|             cctv,cctv|  null|null|
  |  2|   apple iphone,iphone|phones|null|
  |  3|           ,spy camera|  null|null|
  +---+----------------------+------+----+
  </code></pre>
  
  <p>I have done like below.</p>
  
  <pre><code>df1 = df.withColumn('cat', F.when(df.con.isin(phone_list), 'phones')).withColumn('abc', F.when(df.con.isin(pc_list), 'pc'))
  </code></pre>
  
  <p><code>output</code></p>
  
  <pre><code>df1.show()
  
  +---+----------------------+----+----+
  | id|                   con| cat| abc|
  +---+----------------------+----+----+
  |  3|           mac,mac pro|null|null|
  |  1|        iphone5,iphone|null|null|
  |  1| android,android phone|null|null|
  |  1|    windows,windows pc|null|null|
  |  1| spy camera,spy camera|null|null|
  |  2|               camera,|null|null|
  |  3|             cctv,cctv|null|null|
  |  2|   apple iphone,iphone|null|null|
  |  3|           ,spy camera|null|null|
  +---+----------------------+----+----+
  </code></pre>
  
  <p>How can I do this type of comparison in the correct way?</p>