______________ gives the transpose of a DataFrame.
______________ gives the transpose of a DataFrame.
Solution
✅ Correct Option: 3
In pandas, the attribute DataFrame.T returns the transpose of a DataFrame, swapping its rows and columns. The index becomes the column labels and the column labels become the index.
For example, df.T on a DataFrame with 3 rows and 2 columns gives a DataFrame with 2 rows and 3 columns.
Option 4: pandas has a method DataFrame.transpose(), but it is called with brackets and a lowercase "t". The name Transpose as written does not exist.
Options 1 and 2: TP and Trans are not pandas attributes.
T is an attribute and takes no brackets, so write df.T, not df.T().
Related questions:
2025: 22 May Shift 1
2026: 18 May Shift 2