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