Skip to main contentSkip to solution

______________ 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().

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question