700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python地图制作 - pyecharts(1.9.1)绘制各城市地图

python地图制作 - pyecharts(1.9.1)绘制各城市地图

时间:2020-03-07 07:48:17

相关推荐

python地图制作 - pyecharts(1.9.1)绘制各城市地图

准备工作:

一份清洗好的数据,当然你也可以设置随机数(pip install random)。pip install pyecharts 、pip install pandas 成功后选择自己需要的下载,如

pip install echarts-countries-pypkg

pip install echarts-china-provinces-pypkg

pip install echarts-china-cities-pypkg

pip install echarts-china-counties-pypkg

pip install echarts-china-misc-pypkg

pip install echarts-united-kingdom-pypkg

参考代码:

from pyecharts.charts import Map # 新旧版本不同from pyecharts import options as opts #引入配置项入口import pandas as pddata = pd.read_excel('./test.xlsx')data1 = data.groupby('城市').count()num = pd.Series(data1.iloc[:,1]) # 切片取任意一列area = list(num.index)values = list(num) china_area = (Map().add('',list(zip(area,values)), 'china-cities') # zip是新旧版本差异,china-cities指的是maptype.set_global_opts(title_opts=opts.TitleOpts(title='部分城市招聘数量'),visualmap_opts=opts.VisualMapOpts(min_=1,max_=1300, # num.max()is_piecewise=False) #分段).set_series_opts(# 标签名称显示,默认为Truelabel_opts=opts.LabelOpts(is_show=False, color="blue")).render("map_chinacities.html"))

参考文章

/qq_38161040/article/details/122850961#comments_21105301/u010070526/article/details/81782082?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165286208916781483766954%2522%252C%2522scm%2522%253A%25220713.130102334..%2522%257D&request_id=165286208916781483766954&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-2-81782082-null-null.142^v10^control,157^v4^new_style&utm_term=python%E5%9C%B0%E5%9B%BE&spm=1018.2226.3001.4187

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。