List of LISTS of tuples to Pandas dataframe?

前端 未结 4 1907
花落未央
花落未央 2021-01-13 09:39

I have a list of lists of tuples, where every tuple is of equal length, and I need to convert the tuples to a Pandas dataframe in such a way that the columns of the datafram

4条回答
  •  隐瞒了意图╮
    2021-01-13 10:01

    tupList = [[('commentID', 'commentText', 'date'), ('123456', 'blahblahblah', '2019')], [('45678', 'hello world', '2018'), ('0', 'text', '2017')]]
    print(pd.DataFrame(sum(tupList,[])))
    

    Output

               0             1     2
    0  commentID   commentText  date
    1     123456  blahblahblah  2019
    2      45678   hello world  2018
    3          0          text  2017
    

提交回复
热议问题