0

I'm trying to add names to my columns and indices of a pandas dataframe.

Right now,

Int64Index([2, 4, 5, 32, 112, 344, 543],
          dtype='int64')

is my list of column names. I want to make this such that we have

Int64Index([2, 4, 5, 32, 112, 344, 543],
          dtype='int64', name='mid')

instead, so the 'mid' shows up as a label for the top column.

How do I do this? I tried setting

df.columns=
Int64Index([2, 4, 5, 32, 112, 344, 543],
          dtype='int64', name='mid')

but I got an error that Int64Index is not defined. I don't understand this. How do I just simply add a name to my index?

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.