title: Flatten nested array pyspark columns
body: <p>I have said schema in my dataframe structure. I was just wondering what would be the best way of flattening all of these so I can have a full viewable dataframe without arrays.</p>
  <pre><code>root
       |-- id: string (nullable = true)
       |-- InsuranceProvider: string (nullable = true)
       |-- Type: struct (nullable = true)
       |    |-- Client: struct (nullable = true)
       |    |    |-- PaidIn: struct (nullable = true)
       |    |    |    |-- Insuranceid: string (nullable = true)
       |    |    |    |-- Insurancedesc: string (nullable = true)
       |    |    |    |-- purchaseditems: array (nullable = true)
       |    |    |    |    |-- element: struct (containsNull = true)
       |    |    |    |    |    |-- InsuranceNumber: string (nullable = true)
       |    |    |    |    |    |-- InsuranceLabel: string (nullable = true)
       |    |    |    |    |    |-- Insurancequantity: integer (nullable = true)
       |    |    |    |    |    |-- Insuranceprice: integer (nullable = true)
       |    |    |    |    |    |-- discountsreceived: array (nullable = true)
       |    |    |    |    |    |    |-- element: struct (containsNull = true)
       |    |    |    |    |    |    |    |-- amount: integer (nullable = true)
       |    |    |    |    |    |    |    |-- description: string (nullable = true)
       |    |    |    |    |    |-- childItems: array (nullable = true)
       |    |    |    |    |    |    |-- element: struct (containsNull = true)
       |    |    |    |    |    |    |    |-- InsuranceNumber: string (nullable = true)
       |    |    |    |    |    |    |    |-- InsuranceLabel: string (nullable = true)
       |    |    |    |    |    |    |    |-- Insurancequantity: double (nullable = true)
       |    |    |    |    |    |    |    |-- Insuranceprice: integer (nullable = true)
       |    |    |    |    |    |    |    |-- discountsreceived: array (nullable = true)
       |    |    |    |    |    |    |    |    |-- element: struct (containsNull = true)
       |    |    |    |    |    |    |    |    |    |-- amount: integer (nullable = true)
       |    |    |    |    |    |    |    |    |    |-- description: string (nullable = true)
       |-- eventTime: string (nullable = true)
  </code></pre>