【发布时间】:2014-07-11 11:50:09
【问题描述】:
我采用了一个名为“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' 时,它会返回:
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
如何恢复原始表单?
【问题讨论】:
标签: python pandas append series