【发布时间】:2017-06-21 03:53:54
【问题描述】:
在 Pandas 中,我有一个系列和一个多索引:
s = pd.Series([1,2,3,4], index=['w', 'x', 'y', 'z'])
idx = pd.MultiIndex.from_product([['a', 'b'], ['c', 'd']])
对我来说,创建一个以 idx 作为索引、以 s 作为每一行的值、将 S 中的索引保留为列的 DataFrame 的最佳方法是什么?
df =
w x y z
a c 1 2 3 4
d 1 2 3 4
b c 1 2 3 4
d 1 2 3 4
【问题讨论】: