Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created June 5, 2020 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/73ed6c9e90ac24c2fcfe2bf170d77d9e to your computer and use it in GitHub Desktop.
Save aniruddha27/73ed6c9e90ac24c2fcfe2bf170d77d9e to your computer and use it in GitHub Desktop.
row_list = []
# df2 contains all sentences from all speeches
for i in range(len(df2)):
sent = df2.loc[i,'Sent']
if (',' not in sent) and (len(sent.split()) <= 15):
year = df2.loc[i,'Year']
length = len(sent.split())
dict1 = {'Year':year,'Sent':sent,'Len':length}
row_list.append(dict1)
# df with shorter sentences
df3 = pd.DataFrame(columns=['Year','Sent',"Len"])
df3 = pd.DataFrame(row_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment