title: Keeping nested columns a PySpark dataframe
body: <p>Suppose we have a dataframe <code>df</code> with the following schema:</p>
  <pre><code> |-- a: decimal(10,2) (nullable = true)
   |-- b: decimal(10,2) (nullable = true)
   |-- c: decimal(10,2) (nullable = true)
   |-- d: decimal(10,2) (nullable = true)
   |-- array_a: array (nullable = true)
   |    |-- element: struct (containsNull = true)
   |    |    |-- a1: string (nullable = true)
   |    |    |-- a2: integer (nullable = true)
   |    |    |-- a3: string (nullable = true)
   |-- array_b: array (nullable = true)
   |    |-- element: struct (containsNull = true)
   |    |    |-- b1: string (nullable = true)
   |    |    |-- b2: integer (nullable = true)
   |    |    |-- b3: string (nullable = true)
    |-- e: decimal(10,2) (nullable = true)
    |-- f: decimal(10,2) (nullable = true)
    |-- g: decimal(10,2) (nullable = true)
  </code></pre>
  <p>How do you keep the elements of <code>array_a</code> when exploding out <code>array_b</code>? This code doesn't seem to keep <code>array_a</code>:</p>
  <pre><code>from pyspark.sql.functions import explode_outer
  cols = df.columns
  df_a = df.select(*cols, explode_outer(&quot;array_a&quot;)).select(*cols, &quot;col.*&quot;)
  cols_a = df_a.columns
  cols.extend(cols_a)
  df_b = df.select(*cols, explode_outer(&quot;array_b&quot;)).select(*cols, &quot;col.*&quot;)
  </code></pre>