Created
July 22, 2019 10:23
-
-
Save wandabwa2004/7ffcb9d5a954dc24a416886badac3b36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ot = df.sample(frac=.1, random_state=1111) | |
ot.sort_index(inplace=True) | |
ot['mean'] = ot['compound'].expanding().mean() | |
ot['rolling'] = ot['compound'].rolling('12h').mean() | |
fig = plt.figure(figsize=(20,5)) | |
ax = fig.add_subplot(111) | |
ax.scatter(ot['review date'],ot['compound'], label='Tweet Sentiment') | |
ax.plot(ot['review date'],ot['rolling'], color ='g', label='Rolling Mean') | |
ax.plot(ot['review date'],ot['mean'], color='r', label='Expanding Mean') | |
ax.set(title='Te Papa Trip Advisor Reviews over Time', xlabel='Date', ylabel='Sentiment') | |
ax.legend(loc='best') | |
fig.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment