title: Add a new column in dataframe with user defined values. (pyspark)
body: <p>Three values of array A1 getting from some function - </p>
  
  <pre><code>A1 = [1,2,3,4]
  A1 = [5,6,7,8]
  A1 = [1,3,4,1]
  </code></pre>
  
  <p>My dataframe in which I want to add a new column with my array values - </p>
  
  <pre><code>+---+---+-----+
  | x1| x2|   x3|
  +---+---+-----+
  |  1|  A|  3.0|
  |  2|  B|-23.0|
  |  3|  C| -4.0|
  +---+---+-----+
  </code></pre>
  
  <p>I tried like this(Suppose 'df' is my dataframe) - </p>
  
  <pre><code>for i  in range(0, 2):
     df = df.withColumn("x4", array(lit(A1[0]), lit(A1[1]), lit(A1[2]))
  </code></pre>
  
  <p>But problem with this code is it is updating column with last value of array 'A1' like this - </p>
  
  <pre><code>+---+---+-----+---------+
  | x1| x2|   x3|       x4|
  +---+---+-----+---------+
  |  1|  A|  3.0|[1,3,4,1]|
  |  2|  B|-23.0|[1,3,4,1]|
  |  3|  C| -4.0|[1,3,4,1]|
  +---+---+-----+---------+
  </code></pre>
  
  <p>But I want like this - </p>
  
  <pre><code>+---+---+-----+---------+
  | x1| x2|   x3|       x4|
  +---+---+-----+---------+
  |  1|  A|  3.0|[1,2,3,4]|
  |  2|  B|-23.0|[5,6,7,8]|
  |  3|  C| -4.0|[1,3,4,1]|
  +---+---+-----+---------+
  </code></pre>
  
  <p>What i need to add extra in my code?</p>