Which of the following syntax is used to transpose a DataFrame?
Which of the following syntax is used to transpose a DataFrame?
Solution
✅ Correct Option: 2
In pandas, DataFrame.T is the attribute that returns the transpose of a DataFrame, swapping its rows and columns. For example, df.T gives the transposed DataFrame.
Option 1: the transpose method exists, but it must be called as DataFrame.transpose() with parentheses. Without them, it is only a reference to the method and does not transpose anything.
Related questions:
2026: 29 May Shift 2