title: Convert dataframe from wide to long - pandas
body: <p>I have a dataframe like this:</p>
  <pre><code>index    S_1 S_2 S_3 S_4
   0        1    0   0   1
   1        1    1  Nan Nan
  </code></pre>
  <p>I am trying to change it from long to wide. Eg.</p>
  <pre><code>index num S
   0     1  1
   0     2  0
   0     3  0
   0     4  1
   1     1  1
   1     2  1
   1     3  Nan
   1     4  Nan
  </code></pre>
  <p>I have tried the following code, based on <a href="https://stackoverflow.com/questions/45123924/convert-pandas-dataframe-from-wide-to-long">this</a> answer, but I get the following error:</p>
  <pre><code>matches_df.columns = matches_df.columns.str.split('_', expand=True)
  </code></pre>
  <p>TypeError: object of type 'float' has no len()</p>
  <p>Why am I unable to split on the &quot;_&quot;? There is other information in the columns which I would like to preserve.</p>