title: How to get values of multi valued array into a single row
body: <p>I have json file that contains nested arrays. I am using explode function to flatten the json. Below is the sample:</p>
  <pre><code>    &quot;bullet_point&quot;: [
        {
          &quot;language_tag&quot;: &quot;en_US&quot;,
          &quot;value&quot;: &quot;Perfect for trick-or-treat candy, snacking, and packing in lunches&quot;
        },
        {
          &quot;language_tag&quot;: &quot;en_US&quot;,
          &quot;value&quot;: &quot;Snack size&quot;,
         
        },
        {
          &quot;language_tag&quot;: &quot;en_US&quot;,
          &quot;value&quot;: &quot;Dark chocolate coconut candy bars&quot;,
         
        },
        {
          &quot;language_tag&quot;: &quot;en_US&quot;,
          &quot;value&quot;: &quot;Gluten-free and kosher&quot;,
         
        },
        {
          &quot;language_tag&quot;: &quot;en_US&quot;,
          &quot;value&quot;: &quot;Includes 6 bags of MOUNDS Dark Chocolate Candy Bar Snack Size (11.3-Ounce bags)&quot;,
         
        }
  </code></pre>
  <p>A row is created for every bullet point but I want all the values to be in one row(different column). Below is the sample:
  <a href="https://i.stack.imgur.com/NvCtp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NvCtp.png" alt="enter image description here" /></a></p>
  <p>Below is the code to flatten the arrays:</p>
  <pre><code>array_cols = [c[0] for c in nested_df.dtypes if c[1][:5] == 'array']
  for col in array_cols:
      nested_df =nested_df.withColumn(col, F.explode_outer(nested_df[col]))
  </code></pre>
  <p>Is there any function in pyspark to flatten the array into a single row(different columns). Any help will be highly appreciated.</p>