title: Positional argument error when using 'when' in pyspark
body: <pre><code>import pyspark.sql.functions as f
  df_categories4 = df_categories3.select("alias", "title", 
  f.when(df_categories.parents == 0).otherwise(df_categories3.parents[0])).show()
  </code></pre>
  
  <p>It shows an error of when() missing 1 required positional argument: 'value'. But if i place a value after the '0', it says that there is an error that can't be resolve.</p>
  
  <p>How would I approach this problem?</p>
  
  <p>Thanks.</p>
  
  <p><strong>Original Error:</strong></p>
  
  <pre><code>TypeError: when() missing 1 required positional argument: 'value'
  </code></pre>
  
  <p><strong>Error After Entering Value after 0:</strong></p>
  
  <pre><code>AnalysisException: "cannot resolve '(`parents` = 0)' due to data type mismatch: 
  differing types in '(`parents` = 0)' (array&lt;string&gt; and int).;;\n'Project 
  [alias#226, title#230, CASE WHEN (parents#229 = 0) THEN 1 ELSE parents#229[0] 
  END AS CASE WHEN (parents = 0) THEN 1 ELSE parents[0] END#1079]\n+- 
  AnalysisBarrier\n      +- Filter ((array_contains(country_whitelist#228, US) || 
  array_contains(country_whitelist#228, CA)) || isnull(country_whitelist#228))\n         
  +- Filter (NOT (array_contains(country_blacklist#227, US) &amp;&amp; 
  array_contains(country_blacklist#227, CA)) || isnull(country_blacklist#227))\n            
  +- 
  </code></pre>
  
  <p>Relation[alias#226,country_blacklist#227,country_whitelist#228,parents#229,title#230] json\n"</p>