PySpark: multiple conditions in when clause
<p>I would like to modify the cell values of a dataframe column (Age) where currently it is blank and I would only do it if another column (Survived) has the value 0  for the corresponding row where it is blank for Age. If it is 1 in the Survived column but blank in Age column then I will keep it as null. </p>

<p>I tried to use <code>&amp;&amp;</code> operator but it didn't work. Here is my code:</p>

<pre class="lang-none prettyprint-override"><code>tdata.withColumn("Age",  when((tdata.Age == "" &amp;&amp; tdata.Survived == "0"), mean_age_0).otherwise(tdata.Age)).show()
</code></pre>

<p>Any suggestions how to handle that? Thanks.</p>

<p>Error Message:</p>

<pre><code>SyntaxError: invalid syntax
  File "&lt;ipython-input-33-3e691784411c&gt;", line 1
    tdata.withColumn("Age",  when((tdata.Age == "" &amp;&amp; tdata.Survived == "0"), mean_age_0).otherwise(tdata.Age)).show()
                                                    ^
</code></pre>