In [1]:
%matplotlib inline
In [2]:
import datetime
import matplotlib
import pandas as pd
matplotlib.rcParams['figure.figsize'] = (12.0, 4.0)
In [3]:
tweets = pd.read_csv("data/tweets.tsv", sep="\t")
times = tweets.created_at.apply(lambda x: datetime.datetime.strptime(x.split(" ", 1)[1], "%b %d %H:%M:%S +0000 %Y") if type(x) == str else None)
dt_ndx = pd.DatetimeIndex(times)
sr = pd.Series([1] * len(dt_ndx), index=dt_ndx)
daily_count = sr.resample('1D', how=sum)
daily_count = daily_count.ix[-92:]
In [4]:
daily_count.plot()
Out[4]:
In [5]:
hourly_count = sr.resample('1H', how=sum)
hourly_count[-2208:].plot()
Out[5]: