I have a dataframe like this:
ip name
0 10.1.1.1 aa
1 10.1.1.2 bb
I want to remove index column and set ip for index:
ip name
10.1.1.1 aa
10.1.1.2 bb
reset_index() and df.index.name not working...
Set desired and drop current:
df.set_index('ip', drop=True)
As it was pointed out in one of the comments, to make changes inplace you can use either:
df.set_index('ip', drop=True, inplace=True)
or
df = df.set_index('ip', drop=True)
df.set_index('ip')- has been answered before.df = df.set_index('ip')df, you can usedf.reset_index(drop=True, inplace=True)df = df.set_index('ip')