DEV Community

GharamElhendy
GharamElhendy

Posted on

Transposing an Entire Table in Pandas

Importing and parsing

Import pandas as pd
df = pd.read_csv('table.csv')


To transpose

df = pd.read_csv('table.csv', skiprows=1, header=None).T


You can check that it was transposed with all the columns and rows correctly by using the shape attribute:

df.shape


If it used to result, for example, in (10,5) and it became (5,10) after the transpose, then you're all done!

Top comments (0)