This does not really apply to your case, but it may be useful to know to others (such as me 5 minutes ago). If one multi-index has the same names as this:
value Trial Trial 1 0 13 1 3 2 4 2 0 NaN 1 12 3 0 34
df.reset_index(inplace=True) will cause the created columns to not have common names.
Then you need to rename the multi-index with df.index = df.index.set_names(['Trial', 'measurement']) to get:
value Trial measurement 1 0 13 1 1 3 1 2 4 2 0 NaN 2 1 12 3 0 34
And then df.reset_index(inplace=True) will work like a charm.
I ran into this problem after grouping by year and month by datetime column (not by index) with the name live_date , which meant that both year and month were called live_date .
Karl Anka Nov 17 '17 at 17:46 on 2017-11-17 17:46
source share