我选择了一个名为“ dat”的多索引熊猫系列,并尝试将其附加到一个名为“ s”的空系列中。这是'dat'的样子:
a = [['bar', 'bar', 'foo', 'foo'],['one', 'two', 'one', 'two']]
t = list(zip(*a))
ind = pd.MultiIndex.from_tuples(t, names=['first', 'second'])
dat = pd.Series(randn(4), index=ind)
Out[1]:
first second
bar one -1.361606
two -0.108458
foo one -0.691175
two -0.830161
dtype: float64
现在,当我将其附加到空Series时,它将返回以下内容:
s = pd.Series()
s = s.append(dat)
Out[2]:
(bar, one) -1.361606
(bar, two) -0.108458
(foo, one) -0.691175
(foo, two) -0.830161
dtype: float64
我该如何找回原始表格?
这是在0.14.0中修复的错误(将于下周发布),请参见此处:http ://pandas-docs.github.io/pandas-docs-travis/whatsnew.html#whatsnew-0140-api(set_index部分) 。
您可以在此处获取预发布版本:https://github.com/pydata/pandas/releases
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句