Skip to main contentSkip to solution

Indexes or labels of a row or column can be changed in a DataFrame using ____________________.

Solution

✅ Correct Option: 1

set_index() makes one or more existing columns the row index of a DataFrame, and reset_index() moves the index back into a column and replaces it with the default 0, 1, 2... labels. Both change the row labels of a DataFrame.


Options 2, 3 and 4: alter_index, pivot_index, update_index and modify_index are not pandas methods. pivot() and pivot_table() exist, but there is no pivot_index.

The rename() method can also change individual row or column labels.

Keyboard Shortcuts

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