结果
我的代码
# coding: utf-8
import pymongo
import charts
client = pymongo.MongoClient('localhost',27017)
ganji2 = client['ganji2']
item_info = ganji2['item_info']
cates_ori = []
for i in item_info.find():
cates_ori.append(i['cate'][2])
cates_set = list(set(cates_ori))
print(cates_set)
post_times = []
for index in cates_set:
post_times.append(cates_ori.count(index))
print(post_times)
def get_data_gen(chart_type):
for cate,times in zip(cates_set, post_times):
data = {
'name':cate,
'data':[times],
'type':chart_type
}
yield data
series = [data for data in get_data_gen('column')]
print(series)
charts.plot(series, show='inline', options=dict(title=dict(text='Chars are Awesome!')))
数据分析
分类 |
跟帖数量 |
二手闲置礼品 |
6402 |
办公设备 |
6424 |
二手虚拟物品 |
6677 |
农产品 |
6414 |