Skip to content Skip to sidebar Skip to footer

Changing A Single Index Of A Series

I am trying to change just a particular index of a Series. The indices are Dates. cashflow_series is the Series, and I am just trying to add a certain number of months to this date

Solution 1:

In Pandas, an index is frozen (it is immutable and will give the following error if you try to change a value in the index):

TypeError: '' does not support mutable operations.

You need to create a copy of the old index values, modify it, and then replace the one in your series with this copy. Something like:

idx = df.index.values
idx[3] = '2015-8-15'
df.index = idx

Post a Comment for "Changing A Single Index Of A Series"