-
-
Save loganwilliams/405062de4b4c5aac6c128538d114a772 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
twint = pd.read_csv('tweets.csv', sep='\t', parse_dates=['created_at']) | |
twint['o2'] = twint['tweet'].apply(lambda v: 'oxygen' in v.lower() or 'o2' in v.lower()) | |
grp = twint.groupby(pd.Grouper(freq='4H', key='created_at')) | |
plt.figure(figsize=(6,3)) | |
plt.fill_between(grp.count().index, 0.25*grp.count()['id'], color="#fc8d62", alpha=1.0) | |
plt.fill_between(grp.sum().index, 0.25*grp.sum()['o2'], color='#7570b3', alpha=1.0) | |
plt.xlim(pd.to_datetime('2021-03-10'), pd.to_datetime('2021-04-22 16:00')) | |
plt.ylabel('Unique tweets per hour') | |
plt.legend(['Tweets containing "delhi" and "urgent"', 'Tweets also containing "oxygen"'], loc='upper left') | |
plt.tight_layout() | |
plt.savefig('India.png', dpi=300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment