What is the purpose of the reset_index() in pandas?
What is the purpose of the reset_index() in pandas?
Solution
✅ Correct Option: 2
reset_index() replaces the DataFrame's current index with the default integer index . It is commonly used after filtering or sorting, when the old row labels are no longer in order.
By default, the old index is added back as a new column. Use drop=True to discard it instead.
Option 1: the data values are never changed, only the row labels.
Option 3: removing NaN values is done by dropna(), not reset_index().
Option 4: column names are left as they are, and reset_index() acts only on the row index.
Related questions:
2025: 14 May Shift 1
2026: 13 May Shift 2
2026: 29 May Shift 1
2025: 21 May Shift 1
2026: 31 May Shift 1
2026: 23 May Shift 1