title: PySpark - Pass list as parameter to UDF
body: <p>I need to pass a list into a UDF, the list will determine the score/category of the distance. For now, I am hard coding all distances to be the 4th score.</p>
  
  <pre><code>a= spark.createDataFrame([("A", 20), ("B", 30), ("D", 80)],["Letter", "distances"])
  
  from pyspark.sql.functions import udf
  def cate(label, feature_list):
      if feature_list == 0:
          return label[4]
  label_list = ["Great", "Good", "OK", "Please Move", "Dead"]
  udf_score=udf(cate, StringType())
  a.withColumn("category", udf_score(label_list,a["distances"])).show(10)
  </code></pre>
  
  <p>when I try something like this, I get this error. </p>
  
  <pre><code>Py4JError: An error occurred while calling z:org.apache.spark.sql.functions.col. Trace:
  py4j.Py4JException: Method col([class java.util.ArrayList]) does not exist
      at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
      at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:339)
      at py4j.Gateway.invoke(Gateway.java:274)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:214)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>