You can use the reset_index() function to reset the DataFrame index to its default value. This function will also add 'index' as a new column. To drop it, you can use this function with 'drop=True' parameter.
Here is an example:
>>> import pandas as pd>>> df=pd.DataFrame({'A':[1,2,3,4,5], 'B':[10,20,30,40,50]})>>> df A B0 1 101 2 202 3 303 4 404 5 50>>> df1=df.set_index('C')>>> df1 A BC 11 1 1012 2 2013 3 3014 4 4015 5 50
Without 'drop' parameter
>>> df.reset_index() index A B C0 0 1 10 111 1 2 20 122 2 3 30 133 3 4 40 144 4 5 50 15
With 'drop' parameter
>>> df.reset_index(drop=True) A B C0 1 10 111 2 20 122 3 30 133 4 40 144 5 50 15