Adding a new column as Index

If my data doesn’t have a default index column, how do I add a default index column

I’m not sure if that’s what you mean:
To make an index using an existing column you need to use set_index method of DataFrame object.
df = df.set_index('column_name')
or
df.set_index('column_name', inplace=True)

1 Like