3 回答
TA贡献1858条经验 获得超8个赞
您可以使用pd.DataFrame.from_records和转置:
df = pd.DataFrame.from_records([list1, list2]).T.fillna('')
# df.columns = ['list1', 'list2']
0 1
0 new book revealing potentially embarrassing
1 library for topic modelling several international
2 daily newspaper
TA贡献1796条经验 获得超4个赞
一种方法是使用zip_longest:
import itertools
pd.DataFrame(itertools.zip_longest(list1, list2), columns =['list1', 'list2'])
list1 list2
0 new book revealing potentially embarrassing
1 library for topic modelling several international
2 None daily newspaper
TA贡献1828条经验 获得超4个赞
您可以构建水平df,然后转置。
pd.DataFrame([list1, list2], index=['list1', 'list2']).T.fillna('')
list1 list2
0 new book revealing potentially embarrassing
1 library for topic modelling several international
2 daily newspaper
添加回答
举报