can you swap rows and columns in a pandas dataframe code example
Example 1: dataframe index column invert
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
Example 2: dataframe index column invert
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