Pandas Series index: Change it by assigning to s.index

Pandas Series index: Change it by assigning to s.index

Want to change the index of a Python Pandas series? Just assign to it:

s = pd.Series([10, 20, 30], index=list('abc'))
s.index = list('xyz')
s.index # Index(['a', 'b', 'c'], dtype='str')
s.index = range(10, 18, 2)
s.index # RangeIndex(start=10, stop=15, step=2)