使用python爬取数据并分析2018北京积分落户情况【出图代码】
昨天发完帖子后,有同学问出图是用的哪个库,现在把出图的代码贴上,用的是pyecharts。上一篇帖子 使用python爬取数据并分析2018北京积分落户情况
```
#-*-coding:utf-8-*-
import time
import MySQLdb
import sys
from pandas import DataFrame
from pyecharts import Bar,Pie,Page
defaultencoding = 'utf-8'
if sys.getdefaultencoding() != defaultencoding:
reload(sys)
sys.setdefaultencoding(defaultencoding)
db = MySQLdb.connect("localhost", "root", "root", "py", charset='utf8' )
cursor = db.cursor()
def get_privince_count(dataframe):
indexs = []
counts = []
for index in dataframe.index:
indexs.append(index)
counts.append(dataframe)
print counts
print indexs
page = Page()
labels =
sizes =
attr = indexs
v1 = counts
bar =Bar("积分落户年龄统计图" )
bar.add("地区分布",attr,v1,is_stack=True,is_label_show=True,is_datazoom_show =True,
is_random = True)
page.add(bar)
bar.show_config()
bar.render()
sql = "select name,score,city,unit,year from bjrbj"
cursor.execute(sql)
results = cursor.fetchall()
data = list(results)
data =
df = DataFrame(data, columns=["name","score","city","unit","year"])
score = df['year']
score = score.value_counts()[:10]
get_privince_count(score)
```
免费的评分可以给点儿吗??? 一直在研究python 入门ing 学习一下 恭喜大佬喜提北京户口 感谢楼主热心分享
一直在学Python,研究了一下,很有帮助,爬虫感觉好用,谢谢分享 现在用不到 正在学习python,仔细研读一下,谢谢楼主分享。 好棒 支持一下 {:1_921:} 谢谢楼主分享
页:
[1]