-
Notifications
You must be signed in to change notification settings - Fork 12
/
UserCommentDate.py
52 lines (51 loc) · 1.45 KB
/
UserCommentDate.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
#coding: utf-8
from wordcloud import WordCloud,STOPWORDS
import pandas as pd
import jieba
import matplotlib.pyplot as plt
#import seaborn as sns
from pyecharts import Geo,Style,Line,Bar,Overlap,Map, Pie
import io
import sqlite3
if __name__ == '__main__':
conn = sqlite3.connect('deal_data.db')
conn.text_factory = str
data = pd.read_sql("select * from realData", conn)
movieIdData = data.groupby(['week'])
commentDataCount = movieIdData["week"].agg([ "count"])
commentDataCount.reset_index(inplace=True)
print commentDataCount
weekInfo = {
"Monday":u"周一",
"Tuesday":u"周二",
"Wednesday":u"周三",
"Thursday":u"周四",
"Friday":u"周五",
"Saturday":u"周六",
"Sunday":u"周日"
}
weeks = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday","Sunday"
]
attr = []
v1 = []
week_temp = [commentDataCount["week"][i] for i in range(0, commentDataCount.shape[0])]
for item in weeks:
attr.append(weekInfo[item])
index = week_temp.index(item)
v1.append(commentDataCount["count"][index])
for aa in attr:
print aa
#
# attr = [weekInfo[commentDataCount["week"][i]] for i in range(0, commentDataCount.shape[0])]
# v1 = [commentDataCount["count"][i] for i in range(0, commentDataCount.shape[0])]
bar = Line("天评论数量")
bar.add("数量",attr,v1,is_stack=True,xaxis_rotate=30,yaxix_min=4.2,
xaxis_interval=0,is_splitline_show=True,is_label_show=True)
bar.render("html/comment_week_count.html")