For a data frame df:
Col1 Col2
Key
A 4 10
B 7 10
C 3 9
My desired data frame
A B C
Col1 4 7 3
Col2 10 10 9
Where Col1and Col2are the indices.
How can I indicate this? I tried:
In [419]: mydf.T.reset_index(drop=True)
Out[419]:
Key A B C
0 4 7 3
1 10 10 9
But for some reason it remains Key. I'm not sure what it is, and I'm not sure how to get rid of it. I also tried mydf.T.reset_index().set_index('index'), but it is very unsightly.
source
share