import numpyimport pandas as pdimport matplotlib.pyplot as pltfrom pyecharts.charts import Barfrom pyecharts import options as optsdata = http://www.kingceram.com/post/pd.read_excel("各城市人口2.xlsx")data = http://www.kingceram.com/post/pd.DataFrame(data)people_count = data['count'].values.tolist()range_num = []labes = []j = 1for i in range(0,1700,100):range_num.append(i)labes.append(str(i)+"-"+str(j*100))j+=1range_num.append(5000)labes.pop(-1)labes.append("大于1600")print(range_num,labes)cuts = pd.cut(people_count,range_num,labels=labes)couts_range = cuts.value_counts().values.tolist()bar = Bar(init_opts=opts.InitOpts(width="2000px",height="700px",page_title="各个区间范围的城市数"))bar.add_xaxis(labes)bar.add_yaxis("", couts_range)bar.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=20)),title_opts=opts.TitleOpts(title="区间内的城市数量", subtitle="坐"),datazoom_opts=opts.DataZoomOpts(),)bar.render_notebook()bar.render('全国区间人口2.html')
- Python进阶实践课:泰坦尼克之灾获救预测
- 基于python+django框架校园失物招领系统设计与实现
- “网红”Python,疯狂打 call
- Python3 Anaconda3下import cv2错误解决方案
- 十七 Python工具箱系列
- CentOS 安装python3 遇到的问题
- Python竖版大屏 | 用pyecharts开发可视化的奇妙探索
- python和php对比 青岛儿童python培训班哪家
- 上海python培训学费
- 【附源码】Python计算机毕业设计培训中心管理系统