Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created June 8, 2020 08:32
Show Gist options
  • Save aniruddha27/3d4be25ddfaabddef4aa0b1752cacd9f to your computer and use it in GitHub Desktop.
Save aniruddha27/3d4be25ddfaabddef4aa0b1752cacd9f to your computer and use it in GitHub Desktop.
# 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