forked from qmcs/sw-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeline.py
29 lines (24 loc) · 864 Bytes
/
timeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Timeline plot generator for tweet streams."""
from opster import command
import pandas as pd
import matplotlib.pyplot as plt
@command()
def timeline(
input_file,
output=('o', 'timeline.png', 'The output file name.'),
):
"""Generate a timeline plot for a stream of tweets."""
print('input_file is: {}'.format(input_file))
print('output is: {}'.format(output))
# read the input data into pandas format
dataFrame = pd.io.parsers.read_csv(input_file,
sep=' ',
names=['Date','Count'],
parse_dates=True,
index_col=0)
print dataFrame.head()
# plot and save
dataFrame.plot()
plt.savefig(output)
if __name__ == '__main__':
timeline.command()