To transpose a DataFrame, the ______ is used.
To transpose a DataFrame, the ______ is used.
Solution
✅ Correct Option: 3
The attribute (written df.T) swaps the rows and columns of a DataFrame, so row labels become column labels and the other way round. It is an attribute, so it is written without parentheses.
Option 4: reindex() changes the row or column labels to a new set of labels. It does not swap rows and columns.
Options 1 and 2: reverse() and invert() are not DataFrame methods for transposing. reverse() belongs to Python lists.
Related questions:
2025: 27 May Shift 2
2025: 15 May Shift 2
2026: 21 May Shift 1
2026: 23 May Shift 2
2026: 21 May Shift 1