# method A
df = df.set_index('col')
# method B
df['col'] = df.index
How to convert index of a pandas dataframe into a column
df = df.reset_index(level=0)
df['index1'] = df.index
#Python 3
#Declare list of index
#and just assign it to the existing dataframe
separate_list = [1,2,3,4,5]
df.index = separate_list
index = [1,2]
df.index = index
#cree un indice par defaut sur la base de donnee
df.reset_index()
>>> df.set_index('month')
year sale
month
1 2012 55
4 2014 40
7 2013 84
10 2014 31
Pandas dataframe set-index
Pandas dataframe set-index()
Pandas dataframe set-index
Pandas dataframe set-index
Pandas dataframe set-index
x.index = index_values
Pandas dataframe set-index()
Pandas dataframe set-index()