Regarding the immutability of pandas dataframe indexes

Viewed 3947

I read in the documentation that the index objects are immutable and can not be changed once created. But I can change the values after creation.

Am I missing something here?

This is what I tried:

ser = pd.Series([5,0,3,8,4], index=['red','blue','yellow','white','green'])
ser

red       5
blue      0
yellow    3
white     8
green     4
dtype: int64

ser.index = ['red','blue','yellow','white','test']
ser

red       5
blue      0
yellow    3
white     8
test      4
dtype: int64
2 Answers
Related