title: Splitting a row in a PySpark Dataframe into multiple rows
body: <p>I currently have a dataframe where one column is of type <code>&quot;a b c d e ...&quot;</code>.  Call this column <code>col4</code></p>
  <p>I would like to split a single row into multiple by splitting the elements of <code>col4</code>, preserving the value of all the other columns.</p>
  <p>So, for example, given a df with single row:</p>
  <pre class="lang-text prettyprint-override"><code>|col1[0] | col2[0] | col3[0] | a b c |
  </code></pre>
  <p>I would like the output to be:</p>
  <pre class="lang-text prettyprint-override"><code>|col1[0] | col2[0] | col3[0] | a | 
  |col1[0] | col2[0] | col3[0] | b |
  |col1[0] | col2[0] | col3[0] | c |
  </code></pre>
  <p>Using the split and explode functions, I have tried the following:</p>
  <pre><code>d = COMBINED_DF.select(col1, col2, col3, explode(split(my_fun(col4), &quot; &quot;)))
  </code></pre>
  <p>However, this results in the following output:</p>
  <pre class="lang-text prettyprint-override"><code>|col1[0] | col2[0] | col3[0] | a b c |
  |col1[0] | col2[0] | col3[0] | a b c |
  |col1[0] | col2[0] | col3[0] | a b c |
  </code></pre>
  <p>which is not what I want.</p>