To transpose a Pandas DataFrame in Python, you can use the transpose() function or the .T attribute.
Here's an example:
main.py390 chars16 lines
Both transpose() function and .T attribute will return a new transposed DataFrame. The result will be a DataFrame where the columns of the original DataFrame become rows, and vice versa.
Note that the transposed DataFrame will have the column names of the original DataFrame as index.
Output:
main.py217 chars10 lines
gistlibby LogSnag