title: Apache pyspark How to create a column with array containing n elements
body: <p>I have a dataframe with 1 column of type integer. </p>
  
  <p>I want to create a new column with an array containing n elements (n being the # from the first column)</p>
  
  <p>For example: </p>
  
  <pre><code>x = spark.createDataFrame([(1,), (2,),],StructType([ StructField("myInt", IntegerType(), True)])) 
  
  +-----+
  |myInt|
  +-----+
  |    1|
  |    2|
  |    3|
  +-----+
  </code></pre>
  
  <p>I need the resulting data frame to look like this:</p>
  
  <pre><code>+-----+---------+
  |myInt|    myArr|
  +-----+---------+
  |    1|      [1]|
  |    2|   [2, 2]|
  |    3|[3, 3, 3]|
  +-----+---------+
  </code></pre>
  
  <p>Note, It doesn't actually matter what the values inside of the arrays are, it's just the count that matters.</p>
  
  <p>It'd be fine if the resulting data frame looked like this:</p>
  
  <pre><code>+-----+------------------+
  |myInt|             myArr|
  +-----+------------------+
  |    1|            [item]|
  |    2|      [item, item]|
  |    3|[item, item, item]|
  +-----+------------------+
  </code></pre>