title: Apply UDF to multiple columns in Spark Dataframe
body: <p>I have a dataframe which looks like below    </p>
  
  <pre><code>| id| age|   rbc|  bgr| dm|cad|appet| pe|ane|classification|
  +---+----+------+-----+---+---+-----+---+---+--------------+
  |  3|48.0|normal|117.0| no| no| poor|yes|yes|           ckd|
  ....
  ....
  ....
  </code></pre>
  
  <p>I have written an UDF to convert categorical <code>yes, no, poor, normal</code> into binary <code>0s</code> and <code>1s</code></p>
  
  <pre><code>def stringToBinary(stringValue: String): Int = {
      stringValue match {
          case "yes" =&gt; return 1
          case "no" =&gt; return 0
          case "present" =&gt; return 1
          case "notpresent" =&gt; return 0
          case "normal" =&gt; return 1
          case "abnormal" =&gt; return 0
      }
  }
  
  val stringToBinaryUDF = udf(stringToBinary _)
  </code></pre>
  
  <p>I am applying this to the dataframe as follows</p>
  
  <pre><code>val newCol = stringToBinaryUDF.apply(col("pc")) //creates the new column with formatted value
  val refined1 = noZeroDF.withColumn("dm", newCol) //adds the new column to original
  </code></pre>
  
  <p><strong>How can I pass multiple columns into the UDF so that I don't have to repeat myself for other categorical columns?</strong></p>