0

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...

TheNone
  • 5,684
  • 13
  • 57
  • 98

1 Answers1

2

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)
zipa
  • 27,316
  • 6
  • 40
  • 58
  • set_index('ip') not working . Because print df.index.name is None and df still has a third column – TheNone Oct 12 '17 at 09:42