title: Pandas: Reset index for non unique index
body: <p>I have a dataframe like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>Name</th>
  <th>Value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>x1</td>
  <td>0.20</td>
  </tr>
  <tr>
  <td>0</td>
  <td>x1</td>
  <td>0.40</td>
  </tr>
  <tr>
  <td>0</td>
  <td>x1</td>
  <td>0.34</td>
  </tr>
  <tr>
  <td>3</td>
  <td>x2</td>
  <td>0.12</td>
  </tr>
  <tr>
  <td>3</td>
  <td>x2</td>
  <td>0.13</td>
  </tr>
  <tr>
  <td>4</td>
  <td>x3</td>
  <td>0.19</td>
  </tr>
  <tr>
  <td>4</td>
  <td>x3</td>
  <td>0.23</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>df = pd.DataFrame([[&quot;x1&quot;, 0.2], [&quot;x1&quot;, 0.4], [&quot;x1&quot;, 0.34], [&quot;x2&quot;, 0.12], [&quot;x2&quot;, 0.13], [&quot;x3&quot;, 0.19], [&quot;x3&quot;, 0.239]],  index = [0, 0, 0, 3, 3, 4, 4], columns= [&quot;Name&quot;, &quot;Value&quot;])
  </code></pre>
  <p>I would like to reset the index to get the following DataFrame:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>Name</th>
  <th>Value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>x1</td>
  <td>0.20</td>
  </tr>
  <tr>
  <td>0</td>
  <td>x1</td>
  <td>0.40</td>
  </tr>
  <tr>
  <td>0</td>
  <td>x1</td>
  <td>0.34</td>
  </tr>
  <tr>
  <td>1</td>
  <td>x2</td>
  <td>0.12</td>
  </tr>
  <tr>
  <td>1</td>
  <td>x2</td>
  <td>0.13</td>
  </tr>
  <tr>
  <td>2</td>
  <td>x3</td>
  <td>0.19</td>
  </tr>
  <tr>
  <td>2</td>
  <td>x3</td>
  <td>0.23</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>df = pd.DataFrame([[&quot;x1&quot;, 0.2], [&quot;x1&quot;, 0.4], [&quot;x1&quot;, 0.34], [&quot;x2&quot;, 0.12], [&quot;x2&quot;, 0.13], [&quot;x3&quot;, 0.19], [&quot;x3&quot;, 0.239]],  index = [0, 0, 0, 1, 1, 2, 2], columns= [&quot;Name&quot;, &quot;Value&quot;])
  </code></pre>
  <p>As this does not seem possible with the reset_index() function, what would be best way to achieve this reindexing?</p>
  <p>The DataFrame results from using explode() and filtering NaN values. I want to reset the index after filtering to make it easier to loop over the exploded values later on. Notice that I don't want to use the &quot;Name&quot; column as the index, as indexing by string seems to be extremly slow for larger data sets.</p>