I would like to convert a Pandas DataFrame in Python with multiple columns and time as index so that column names are transformed in the new index, while time and values appear as two columns. See the example below.
Original DataFrame
p1 p2 p3
1 1 4 7
6 2 5 8
11 3 6 9
Resulting DataFrame
time vals
p1 1 1
p1 6 2
p1 11 3
p2 1 4
p2 6 5
p2 11 6
p3 1 7
p3 6 8
p3 11 9
I am looking for a relatively fast solution as my dataframe is large and I have to redo the transformation many times.