title: convert array to struct pyspark
body: <p>I'm quite new to pyspark and I have a dataframe that currently looks like below.</p>
  <pre><code>| col1                            | col2              |
  +---------------------------------+-------------------+
  | [(a, 0)], [(b,0)].....[(z,1)]   | [0, 0, ... 1]     |
  | [(b, 0)], [(b,1)].....[(z,0)]   | [0, 1, ... 0]     |
  | [(a, 0)], [(c, 1)].....[(z,0)]  | [0, 1, ... 0]     |
  </code></pre>
  <p>I extracted values from <code>col1.QueryNum</code> into col2 and when I print the schema, it's an array containing the list of number from <code>col1.QueryNum</code>.</p>
  <p>Ultimately my goal is to convert the list values in <code>col2</code> into struct format inside pyspark(refer to desired schema).</p>
  <p><strong>Current Schema</strong></p>
  <pre><code> |-- col1: array (nullable = true)
   |    |-- element: struct (containsNull = true)
   |    |    |-- types: string (nullable = true)
   |    |    |-- QueryNum: integer (nullable = true)
   |-- col2: array (nullable = true)
   |    |-- element: integer (containsNull = true)
  
  </code></pre>
  <p><strong>Desired Schema</strong></p>
  <pre><code> |-- col2: array (nullable = true)
   |    |-- element: struct (containsNull = true)
   |    |    |-- val1: integer (nullable = true)
   |    |    |-- val2: integer (nullable = true)
                   .
                   .
                   .
   |    |    |-- val80: integer (nullable = true)
  </code></pre>
  <p>I tried using <code>from_json</code> and it's not really working.</p>