问题描述
我正在尝试将 pd.series 转换为 pd.df
我有下一个 df:
COL1
0 a
1 b
2 c
3 d
4 e
5 f
. .
. .
n n
我需要像这样转换它:
COL1 COL2 COL3
0 a b c
1 d e f
. . . .
. . . .
n n n n
解决方法
让我们试试reshape
out = pd.DataFrame(df.COL1.values.reshape((-1,3)))
Out[243]:
0 1 2
0 a b c
1 d e f