title: Add a New column in pyspark Dataframe (alternative of .apply in pandas DF)
body: <p>I have a pyspark.sql.DataFrame.dataframe <strong>df</strong></p>
  
  <pre class="lang-python prettyprint-override"><code>id    col1
  1       abc
  2       bcd
  3       lal
  4       bac
  </code></pre>
  
  <p>i want to add one more column <strong>flag</strong> in the df such that if id is odd no, flag should be 'odd' , if even 'even' </p>
  
  <p>final output should be</p>
  
  <pre class="lang-python prettyprint-override"><code>id    col1    flag
  1       abc    odd
  2       bcd    even
  3       lal    odd
  4       bac    even
  </code></pre>
  
  <p>I tried:</p>
  
  <pre class="lang-python prettyprint-override"><code>def myfunc(num):
      if num % 2 == 0:
          flag = 'EVEN' 
      else:
          flag = 'ODD' 
      return flag
  
  df['new_col'] = df['id'].map(lambda x: myfunc(x))
  df['new_col'] = df['id'].apply(lambda x: myfunc(x))
  </code></pre>
  
  <p>It Gave me error : <code>TypeError: 'Column' object is not callable</code></p>
  
  <p>How do is use .apply ( as i use in pandas dataframe) in pyspark</p>