title: PySpark - ValueError: Cannot convert column into bool
body: <p>So I've seen this solution:</p>
  
  
  
  <p><a href="https://stackoverflow.com/questions/48282321/valueerror-cannot-convert-column-into-bool">ValueError: Cannot convert column into bool</a></p>
  
  <p>which has the solution I think. But I'm trying to make it work with my dataframe and can't figure out how to implement it.</p>
  
  <p>My original code:</p>
  
  <pre class="lang-python prettyprint-override"><code>if df2['DayOfWeek']&gt;=6 : 
     df2['WeekendOrHol'] = 1
  </code></pre>
  
  <p>this gives me the error:</p>
  
  <blockquote>
    <p>Cannot convert column into bool: please use '&amp;' for 'and', '|' for
    'or', '~' for 'not' when building DataFrame boolean expressions.</p>
  </blockquote>
  
  <p>So based on the above link I tried:</p>
  
  <pre class="lang-python prettyprint-override"><code>from pyspark.sql.functions import when
  when((df2['DayOfWeek']&gt;=6),df2['WeekendOrHol'] = 1)   
  when(df2['DayOfWeek']&gt;=6,df2['WeekendOrHol'] = 1)
  </code></pre>
  
  <p>but this is incorrect as it gives me an error too.</p>