title: Convert int column to list type pyspark
body: <p>My DataFrame has a column <code>num_of_items</code>. It is a count field. Now, I want to convert it to list type from int type.</p>
  
  <p>I tried using <code>array(col)</code> and even creating a function to return a list by taking int value as input. Didn't work</p>
  
  <pre class="lang-python prettyprint-override"><code>from pyspark.sql.types import ArrayType
  from array import array
  
  def to_array(x):
      return [x]
  
  df=df.withColumn("num_of_items", monotonically_increasing_id())
  </code></pre>
  
  <p>df</p>
  
  <pre class="lang-python prettyprint-override"><code>col_1    | num_of_items
  A        |  1
  B        |  2
  </code></pre>
  
  <p>Expected output</p>
  
  <pre class="lang-python prettyprint-override"><code>col_1    | num_of_items
  A        | [23]
  B        | [43]
  </code></pre>