title: Adding a Arraylist value to a new column in Spark Dataframe using Pyspark
body: <p>I want add a new column in my existing dataframe. Below is my dataframe - </p>
  
  <pre><code>+---+---+-----+
  | x1| x2|   x3|
  +---+---+-----+
  |  1|  a| 23.0|
  |  3|  B|-23.0|
  +---+---+-----+
  </code></pre>
  
  <p>I am able to add <code>df = df.withColumn("x4", lit(0))</code> like this </p>
  
  <pre><code>+---+---+-----+---+
  | x1| x2|   x3| x4|
  +---+---+-----+---+
  |  1|  a| 23.0|  0|
  |  3|  B|-23.0|  0|
  +---+---+-----+---+
  </code></pre>
  
  <p>but I want to add a array list to my df.</p>
  
  <p>Supose this <code>[0,0,0,0]</code> is my array to add and after adding my df will look like this - </p>
  
  <pre><code>+---+---+-----+---------+
  | x1| x2|   x3|       x4|
  +---+---+-----+---------+
  |  1|  a| 23.0|[0,0,0,0]|
  |  3|  B|-23.0|[0,0,0,0]|
  +---+---+-----+---------+
  </code></pre>
  
  <p>I tried like this - </p>
  
  <pre><code>array_list = [0,0,0,0]
  df = df.withColumn("x4", lit(array_list))
  </code></pre>
  
  <p>But it is giving error </p>
  
  <pre><code>py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.sql.functions.lit.
  : java.lang.RuntimeException: Unsupported literal type class java.util.ArrayList [0, 0, 0, 0, 0, 0]
  </code></pre>
  
  <p>Do anybody know how to do this?</p>