Skip to content

Instantly share code, notes, and snippets.


loganwilliams/ Secret

Created Apr 22, 2021
What would you like to do?
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.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.savefig('India.png', dpi=300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment