Reputation: 11
I have to transpose my csv file datas using python:
Actual output:
sen 1.2
zen 2.2
ben 3.3
Expected output:
sen zen ben
1.2 2.2 3.3
I want to get sen
, zen
, and ben
to be displayed horizontally in a straight row and the values under it
Upvotes: 1
Views: 211
Reputation: 172
If data is in numpy matrix use
numpy.transpose(matrix)
If data is in Pandas use
df.T
For any other format you have to use loops
Refer the link [https://www.geeksforgeeks.org/transpose-matrix-single-line-python/][1]
Upvotes: 1