Skip to content
Advertisement

Difference between transpose() and .T in Pandas

I have a sample of data:

JavaScript

I want to display simple statistics of the dataset in pandas using describe() method.

JavaScript

Output 1:

result_1

Is there any difference between the two workflows when I am ending up with the same result?

JavaScript

Output 2:

result_1


References:

Advertisement

Answer

There is no difference. As mentioned in the T attribute documentation, T is simply an accessor for the transpose() method. Indeed a quick look in the pandas DataFrame source code shows that the entire implementation of T is nothing more than:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement