Pandas > Set index

Name
Code
Output
dataframe = pandas.DataFrame(numpy.random.randint(0,10,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
print ("dataframe index")
print (dataframe.index.values)
dataframe.set_index('C2',inplace = True)
print ("dataframe new index")
print (dataframe.index.values)
dataframe
   C1  C2  C3
0   8   6   9
1   1   2   0
2   2   4   5
3   0   1   7
4   3   2   2
dataframe index
[0 1 2 3 4]
dataframe new index
[6 2 4 1 2]