How to solve ValueError: Index contains duplicate entries, cannot reshape
<p>I'm trying to unstack a MultiIndex Series so that I can plot the Series against one another.</p>

<pre><code>import pandas as pd
import numpy as np

dicts = {}

index = np.linspace(1, 50)
index[2] = 2.0
index2 = index.copy()
index2[3] = 3.0

for n in range(5):
    if n == 1:
        dicts['test' + str(n)] = pd.Series(np.linspace(0, 20) ** (n / 5),
                                           index=index2)
    else:
        dicts['test' + str(n)] = pd.Series(np.linspace(0, 20) ** (n / 5),
                                           index=index)

s = pd.concat(dicts, names=('test', 'displacement'))
s.unstack(level='test').plot()
</code></pre>

<p>The unstack() in the last line gets <code>ValueError: Index contains duplicate entries, cannot reshape</code>.  The other StackOverflow questions all seem to relate to pivot tables, but I'm not trying to aggregate data; simply plot it.</p>

<p>I would like to have 1 plot with 1 line for each test (level 0 of MultiIndex).  Each line would be the Series values versus the displacement (level 1 of MultiIndex).</p>

<p>My hack at the moment is:</p>

<pre><code>for test_name, test in s.groupby(level='test'):
    test.index = test.index.droplevel()
    test.plot()

plt.show()
</code></pre>

<p>Any help would be much appreciated.</p>