赞
踩
使用折线图展示“大数据”相关职位招聘数量差异
Python、Flask
import pandas as pd from flask import Flask,render_template # 读取数据集 data = pd.read_csv("G:\Projects\pycharmeProject-C\Flask\dataset\zl0507.csv") # 检查空值 print(data.isnull().sum()) # 去重 print(data.shape) print(data.loc[data.duplicated()]) data.drop_duplicates(inplace=True) print(data.shape) # 提取筛选大数据信息 dashuju = data['jobName'].str.contains("大数据") print(len(dashuju)) data_sel = data.loc[dashuju,['jobName','detail']] print(data_sel.shape[0]) # 分组聚合 result = data_sel.groupby('jobName').agg(count=('jobName','count')).sort_values('count',ascending=False).reset_index() # 合并数据 list = result.values.tolist() # 可视化 app = Flask(__name__) @app.route("/") def index(): sheets_list = list return render_template("zl0507_02.html",sheets = sheets_list) if __name__ == '__main__': app.run(debug=True)
HTML
<!DOCTYPE html> <html lang="en" style="height:100%"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body style="height:100%"> <div id="container" style="height:100%"></div> <script type="text/javascript" src="../static/echarts.min.js"></script> <script type="text/javascript"> var dom = document.getElementById("container"); var myecharts = echarts.init(dom); var data = [{% for item in sheets %}'{{item.0}}',{%endfor%}]; var data1 = [{% for item in sheets%}{{item.1}},{%endfor%}] var option = null; option = { title:{ text:'大数据职业招聘数量差异' }, grid:{ top:'5%', bottom:'10%', left:'4%', right:'4%', containLabel:true }, legend:{ show:true }, tooltip:{ trigger:'axis', axisPointer:{ type:'shadow' } }, xAxis:{ type:'category', data:data, boundaryGap:true, axisTick:{ alignWithLabel:true }, axisLabel: { interval:0, rotate:90 } }, yAxis:{ type:'value' }, series:[ { name:'大数据职位', type:'line', data:data1 } ] }; if(option && typeof option=='object'){ myecharts.setOption(option); } </script> </body> </html>
效果展示
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。