Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Reset the Index of a pandas DataFrame

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

reset_index

By default reset_index returns a copy rather than modify the original data frame. You can specify inplace = True to overwrite the behavior.

Series

  1. If you drop the original index, you still have a Series. However, if you reset index of a sereis without dropping the original index, you get a data frame.

r1 1 r2 2 r3 3 r4 4 dtype: int64
Loading...
0 1 1 2 2 3 3 4 dtype: int64

DataFrame

Loading...
Loading...
Loading...

Multi-index

Loading...
Loading...
Loading...
Loading...