title: Py4JError: An error occured while calling o129.and. Trace: py4j.Py4JException: Method and ([class java.lang.string]) does not exist
body: <p>I am trying to check for a condition in pyspark dataframe and add values to a column like below:</p>
  
  <p>DF:</p>
  
  <pre><code>cd    id    Location
  A     A     A
  A     AA    A
  A     AAA   
  A     B     B
  A     BB    B
  A     BBB   
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>cd    id    Location
  A     A     A
  A     AA    A
  A     AAA   New_Loc
  A     B     B
  A     BB    B
  A     BBB   New_Loc   
  </code></pre>
  
  <p>I tried to populate using the below pyspark transformation</p>
  
  <pre><code>df_new = df.withColumn('Location',sf.when(df.cd == 'A' &amp; (df.id isin(['AAA','BBB'])),'New_Loc').otherwise(df.Location))
  </code></pre>
  
  <p>When i try to execute this, I am getting the error:
  Py4JError: An error occured while calling o129.and. Trace: py4j.Py4JException: Method and ([class java.lang.string]) does not exist</p>
  
  <p>Any idea whats this error? </p>