pandas set the index of a dataframe to a given column of a datafile code example Example: set index to column pandas df = df.set_index('col') df['col'] = df.index