l = {'col1': [[1,2,3], [4,5,6]]}
df = pd.DataFrame(data = l)
col1
0 [1, 2, 3]
1 [4, 5, 6]
所需的输出:
col1
0 1
1 2
2 3
3 4
4 5
5 6
答案 0 :(得分:3)
这里是explode
df.explode('col1')
col1
0 1
0 2
0 3
1 4
1 5
1 6
答案 1 :(得分:2)
您可以使用np.ravel
展平列表列表:
import numpy as np, pandas as pd
l = {'col1': [[1,2,3], [4,5,6]]}
df = pd.DataFrame(np.ravel(*l.values()),columns=l.keys())
>>> df
col1
0 1
1 2
2 3
3 4
4 5
5 6