Indexes or labels of a row or column can be changed in a DataFrame using ____________________.
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.
Related questions:
2026: 21 May Shift 1
2025: 16 May Shift 1
2025: 21 May Shift 1
2025: 22 May Shift 1
2026: 29 May Shift 2
2026: 31 May Shift 1