Does anyone know why the following code works in python 2.7, but not in python 3?
from pandas import *
df = {'one' : Series([1., 2., 3.], index=['a', 'b', 'c']),
'two' : Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
df = DataFrame(df)
df.index[:] = 0
In 2.7, this returns the following:
Index([0, 0, 0, 0], dtype=object)
Whereas in python 3 I get:
Exception: <class 'pandas.core.index.Index'> object is immutable
I have checked the pandas version and it's 0.12.0 in both cases.
My understanding was that the index is immutable, so I am surprised that this code works in 2.7.
Thanks very much,
Robin