Skip to content

Instantly share code, notes, and snippets.

@liannewriting
Created September 6, 2020 17:26
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 liannewriting/c2493436677b8577b781fd2b75840b56 to your computer and use it in GitHub Desktop.
Save liannewriting/c2493436677b8577b781fd2b75840b56 to your computer and use it in GitHub Desktop.
Twitter sentiment analysis python
df_starbucks['created_at_hour'] = df_starbucks['created_at'].dt.round('H')
aggregation = {'cnt': ('id', 'count')}
df_sentiment_by_time = df_starbucks.groupby(['created_at_hour', 'predicted_sentiment']).agg(**aggregation).reset_index()
df_sentiment_by_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment