unpivot MultiIndex DataFrame with pd.melt()

Give this a try

data_out = data.stack(level=0).rename_axis(['Time','TC']).reset_index()

Out[87]:
   Time   TC Temp   x    z
0     0  TC1  250  10  100
1     0  TC2  255  20  200

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top