14

I have a pandas DataFrame with a single row:

         10  20  30  70
data1:  2.3   5   6   7

I want to reindex the frame so that the column values (10, 20, 30, 70) become index values and the data becomes the column:

    data1:
10     2.3
20     5.0
30     6.0
70     7.0

How do I achieve this?

Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
nom-mon-ir
  • 3,748
  • 8
  • 26
  • 42

1 Answers1

26

You're looking for the transpose (T) method:

In [11]: df
Out[11]:
         10  20  30  70
data1:  2.3   5   6   7

In [12]: df.T
Out[12]:
    data1:
10     2.3
20     5.0
30     6.0
70     7.0
Andy Hayden
  • 359,921
  • 101
  • 625
  • 535