title: PySpark: when function with multiple outputs
body: <p>I am trying to use a "chained when" function.
  In other words, I'd like to get more than two outputs.</p>
  
  <p>I tried using the same logic of the concatenate IF function in Excel: </p>
  
  <pre><code>  df.withColumn("device_id", when(col("device")=="desktop",1)).otherwise(when(col("device")=="mobile",2)).otherwise(null))
  </code></pre>
  
  <p>But that doesn't work since I can't put a tuple into the "otherwise" function.</p>