In [1]:
import pymongo
import charts
Server running in the folder /Users/macbook at 127.0.0.1:55119
In [3]:
client = pymongo.MongoClient('localhost',27017)
db = client['ceshi']
info = db['item_info']
In [48]:
for p in info.find():
    cate = p['cates'][2][2:]
    info.update_one({'_id':p['_id']},{'$set':{'cate':cate}})
In [54]:
types = []
for p in info.find():
    types.append(p['cate'])
typer = list(set(types))
print(typer)
['二手母婴/儿童用品', '二手家具', '二手服装/鞋帽/箱包', '二手平板电脑', '二手文体/户外/乐器', '二手家电', '二手办公用品/设备', '二手美容/保健', '二手设备', '二手数码产品', '二手台式机/配件', '其他二手物品', '二手手机', '二手笔记本', '二手图书/音像/软件']
In [55]:
cnts = []
for p in typer:
    cnts.append(types.count(p))
print(cnts)
[7819, 4891, 9990, 1525, 9510, 18863, 6461, 2794, 1639, 7666, 4855, 1143, 2822, 2651, 4221]
In [56]:
series = []
for name,data in zip(typer,cnts):
    series.append(dict(name=name,data=[data],type='column'))
In [57]:
charts.plot(series,show='inline',options=dict(title=dict(text='二手发帖量')))
Out[57]:

Adjust chart settings

.json