Skip to main contentSkip to solution

Which function will be used to create a new index alongside an already available index?

Solution

✅ Correct Option: 1

df.reset_index() creates a fresh default index (0, 1, 2, ...) and moves the old index into the DataFrame as a normal column. So the new index sits alongside the old index data, which is kept.

Passing drop=True discards the old index instead of keeping it as a column.


Options 2, 3 and 4: drop_index(), remove_index() and index.delete() are not pandas methods for resetting an index. Index.delete(loc) does exist, but it only returns an index with the item at position loc removed. It needs an argument and does not create a new index.

Keyboard Shortcuts

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