I am trying to create a data-frame from a list which has varying lengths for each row.
A sample of the list looks like this (which is how I would like it to)
[(dwstweets gop, broadened, base people), 1]
[(bushs campaign video, features, kat), 2]
[3]
[4]
[5]
[(president obama, wants, york), 6]
[(jeb bush, talked, enforcement), (lets, see, plan), 7]
The code I am using the try and append the list with each row to create the data-frame is:
count = 0;
df2 = pd.DataFrame();
for index, row in df1.iterrows():
doc = nlp(unicode(row));
text_ext = textacy.extract.subject_verb_object_triples(doc);
mylist = list(text_ext) + [index]
count+=1;
df2 = df2.append(mylist, ignore_index=True)
However I get the error:
TypeError: object of type 'int' has no len()
I saw there are several questions with this error but as far as I can see they are not caused by the same thing.
How would I go about creating a data-frame with 7 columns that is unique on the index? (I know many of which will be empty for at least 3 of the columns and all columns except the index)
Thanks.