Invert index and columns in pandas DataFrame

I have a pandas DataFrame with one 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 a column:

  data1: 10 2.3 20 5.0 30 6.0 70 7.0 

How do I achieve this?

+7
source share
1 answer

Are you looking for transpose ( T ):

 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 
+15
source

All Articles