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
A shorter code this:
from itertools import chain
import pandas as pd
tupList = [[('commentID', 'commentText', 'date'), ('123456', 'blahblahblah', '2019')], [('45678', 'hello world', '2018'), ('0', 'text', '2017')]]
new_list = [x for x in chain.from_iterable(tupList)]
df = pd.DataFrame.from_records(new_list)
Edit
You can make the list comprehension directly in the from_records
function.