Pandas 0.12索引在python 3中不可变,在2.7中不是不可变的

时间:2013-11-24 12:40:07

标签: python pandas

有谁知道为什么下面的代码在python 2.7中有效,而在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

在2.7中,这将返回以下内容:

Index([0, 0, 0, 0], dtype=object)

然而在python 3中,我得到了:

Exception: <class 'pandas.core.index.Index'> object is immutable

我检查了熊猫版本,两种情况都是0.12.0。

我的理解是索引是不可变的,所以我很惊讶这段代码在2.7中工作。

非常感谢,

罗宾

0 个答案:

没有答案