Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# create a dataframe containing sentences
df2 = pd.DataFrame(columns=['Sent','Year','Len'])
row_list = []
for i in range(len(df)):
for sent in df.loc[i,'sent']:
wordcount = len(sent.split())
year = df.loc[i,'Year']
dict1 = {'Year':year,'Sent':sent,'Len':wordcount}
row_list.append(dict1)
df2 = pd.DataFrame(row_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment