how to switch columns rows in a pandas dataframe
Solution 1:
You can use df = df.T
to transpose the dataframe. This switches the dataframe round so that the rows become columns.
You could also use pd.DataFrame.transpose()
.
Solution 2:
When using pd.DataFrame.transpose (as suggested by Jamie Bull / coldspeed), be sure to actually write
pd.DataFrame.transpose()
...without the brackets, it didn't work for me.