答案 0 :(得分:1)
尝试一下:
df = pd.DataFrame({
'omega': [
[1, 2, 3, 4, 5, 5],
[1, 2, 3, 4, 5, 5],
[1, 2, 3, 4, 5, 5],
[1, 2, 3, 4, 5, 5],
[1, 2, 3, 4, 5, 5]]
})
df = df['omega'].apply(pd.Series)
print(df)
0 1 2 3 4 5
0 1 2 3 4 5 5
1 1 2 3 4 5 5
2 1 2 3 4 5 5
3 1 2 3 4 5 5
4 1 2 3 4 5 5
答案 1 :(得分:1)
最快的方法是使用使用Series.tolist
获得的值列表来初始化新的 dataframe :
df1 = pd.DataFrame(df['omega'].tolist())
示例:
df = pd.DataFrame({'omega': [np.arange(12).tolist()]* 5})
print(df)
omega
0 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
1 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
3 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
4 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
df1 = pd.DataFrame(df['omega'].tolist()).add_prefix('col')
结果:
# print(df1)
col0 col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11
0 0 1 2 3 4 5 6 7 8 9 10 11
1 0 1 2 3 4 5 6 7 8 9 10 11
2 0 1 2 3 4 5 6 7 8 9 10 11
3 0 1 2 3 4 5 6 7 8 9 10 11
4 0 1 2 3 4 5 6 7 8 9 10 11