Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can pandas read a transposed CSV?

Tags:

python

pandas

csv

Can pandas read a transposed CSV? Here's the file (note I'd also like to select a subset of columns):

A,x,x,x,x,1,2,3
B,x,x,x,x,4,5,6
C,x,x,x,x,7,8,9

Would like to get this DataFrame:

   A  B  C
0  1  4  7
1  2  5  8
2  3  6  9
like image 744
ajwood Avatar asked Sep 08 '16 01:09

ajwood


1 Answers

pd.read_csv('file.csv', index_col=0, header=None).T
like image 166
piRSquared Avatar answered Oct 24 '22 20:10

piRSquared