Last active
September 2, 2020 20:03
-
-
Save josht-jpg/05fdb57b348c0fc24d526236a34ec4a9 to your computer and use it in GitHub Desktop.
Plotting AFINN scores
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
def plot_afinn(df, title): | |
i = 0 | |
scores = [] | |
while i < df.shape[0] - 500: | |
scores.append(df.iloc[i:i + 500].loc[:, 'score'].sum()) | |
i += 500 | |
plt.plot(scores, c=np.random.rand(3,)) | |
plt.ylabel("AFINN score") | |
plt.title(title) | |
plt.xticks([]) | |
#y-axis limits were arrived at from the observed limits in the data. | |
#These should be changed if you're working with a different corpus. | |
plt.ylim(top = 165, bottom = -165) | |
plt.axhline(y = 0, color = 'gray') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment