I have a tidy Dataframe (which I'm not sure how to produce from scratch) such as:
signal condition epoch time value
0 A 0 -1100 0.12
1 A 0 -1080 0.09
2 A 0 -1060 0.08
...
With several conditions A,B,C
. I want to get a DataFrame with multiindex, and the values of value
column as values in the new (and only) columns A, B, C
so in the end it looks like:
value A B C
epoch time
0 -1100 0.12 0.23 0.09
-1080 0.09 0.22 0.10
-1060 0.08 0.19 0.06
...
I tried to first put everything except value
into the index with set_index(['condition','epoch','time'])
and then transpose or pivot but can't get it right somehow (transpose gives me hierarchical columns and pivot KeyError)
I tried e.g.: df.pivot(('epoch','time'),'condition')