title: PySpark WithColumn on multiple columns with udf
body: <p>I have a function in PySpark that takes two input and returns <strong>two output</strong>:</p>
  
  <pre><code>def get_seen_cards(x, y):
      if 1 in x:
          alreadyFailed = 1
      else:
          alreadyFailed = 0
      if y:
          alreadyAuthorized = 1
      else:
          alreadyAuthorized = 0
  return alreadyFailed, alreadyAuthorized
  </code></pre>
  
  <p>And I want to apply this function with udf to get the whole dataframe treated like this:</p>
  
  <pre><code>get_seen_cards_udf = udf(lambda x, y : get_seen_cards_spark(x, y), IntegerType())
  
  data.withColumn(["alr_failed", "alr_auth"], get_seen_cards_udf(data["card_uid"], data["failed"]))
  </code></pre>
  
  <p>Where <code>data["card_uid"]</code> looks like this :</p>
  
  <pre><code>[Row(card_uid='card_1'),
   Row(card_uid='card_2'),
   Row(card_uid='card_3'),
   Row(card_uid='card_4'),
   Row(card_uid='card_5')]
  </code></pre>
  
  <p>and <code>data["failed"]</code> look like this :</p>
  
  <pre><code>[Row(failed=False),
   Row(failed=False),
   Row(failed=False),
   Row(failed=True),
   Row(failed=False)]
  </code></pre>
  
  <p>But this is obvioulsy not working because <em>withColumn</em> only works for <strong>one column</strong>.</p>
  
  <p>I need to add two columns at the same time in my dataframe, the first is the results of the first return of the function and will be stored in "<code>alr_failed</code>" and the other column is the second value of the return and will be store in "<code>alr_auth</code>".</p>
  
  <p>The idea is to return a dataframe with the following columns after treatment : </p>
  
  <pre><code>card_uid, failed, alr_failed, alr_auth
  </code></pre>
  
  <p>Is it even possible someway ? Or is there's a workaround for this ? </p>