renakre
renakre

Reputation: 8291

Indexing is not properly working in pandas dataframe

I have the following data frame with itemid column is bold when printed in the notebook.

itemid   |  user_id  | day1   | day2      
0        |  1232     | 5      | 3
1        |  4107     | 5      | 3
2        |  9262     | 5      | 3
3        |  1031     | 5      | 3

Then I reset the its index using this:

df.index.name = None

But, then I still have the same dataframe. Then, I reset its index using:

df= df.set_index('user_id')

Then, I get this:

item_id  | day1   | day2    
user_id  
1232     | 5      | 3
4107     | 5      | 3
9262     | 5      | 3
1031     | 5      | 3

I have no idea why item_id still stays there. Any ideas?

Upvotes: 2

Views: 716

Answers (1)

akuiper
akuiper

Reputation: 214927

The itemid is the name of your columns, you can try:

df.columns.name = None

Upvotes: 2

Related Questions