spark-dataframe: Create new column with 2 boolean conditions
<p>I would like to mutate my dataframe based on 2 boolean conditions with a bitwise AND operation</p>

<pre class="lang-r prettyprint-override"><code>df %&gt;% mutate(newVariable = ifelse(variable1 == "value1" &amp; variable2 == "value2, variable3, NULL)
</code></pre>

<p>So in PySpark it tested this :</p>

<pre class="lang-py prettyprint-override"><code>import pyspark.sql.functions as func

df.withColumn("newVariable", func.when( \
     func.col("variable1") == "value1" &amp; func.col("variable2") == "value2", \
     func.col("variable3")))
</code></pre>

<p>But I have an error</p>

<p>What is the correct way to create this kind of new variable with spark dataframe ?</p>