title: How to use column names with spaces in stack function in pyspark
body: <p>I tried to unpivot the dataframe and dataframe has folowing structure</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">fstcol</th>
  <th style="text-align: center;">col 1</th>
  <th style="text-align: right;">col 2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">One</td>
  <td style="text-align: center;">1</td>
  <td style="text-align: right;">4</td>
  </tr>
  <tr>
  <td style="text-align: left;">one</td>
  <td style="text-align: center;">2</td>
  <td style="text-align: right;">5</td>
  </tr>
  <tr>
  <td style="text-align: left;">One</td>
  <td style="text-align: center;">3</td>
  <td style="text-align: right;">6</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And I want the dataframe like this :</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">fstcol</th>
  <th style="text-align: center;">col_name</th>
  <th style="text-align: right;">value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">One</td>
  <td style="text-align: center;">col 1</td>
  <td style="text-align: right;">1</td>
  </tr>
  <tr>
  <td style="text-align: left;">one</td>
  <td style="text-align: center;">col 1</td>
  <td style="text-align: right;">2</td>
  </tr>
  <tr>
  <td style="text-align: left;">One</td>
  <td style="text-align: center;">col 1</td>
  <td style="text-align: right;">3</td>
  </tr>
  <tr>
  <td style="text-align: left;">One</td>
  <td style="text-align: center;">col 2</td>
  <td style="text-align: right;">4</td>
  </tr>
  <tr>
  <td style="text-align: left;">one</td>
  <td style="text-align: center;">col 2</td>
  <td style="text-align: right;">5</td>
  </tr>
  <tr>
  <td style="text-align: left;">One</td>
  <td style="text-align: center;">col 2</td>
  <td style="text-align: right;">6</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I have written following code to transform:</p>
  <pre><code>df.selectExpr(&quot;fstcol&quot;,&quot;stack(2, 'col 1', col 1, 'col 2', col 2)&quot;)
  </code></pre>
  <p>however, I am getting an error as column names contains space. It is unable to get the column values for 'col 1' and 'col 2'.</p>
  <p>Can anyone help me to resolve this?</p>