日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python+xlrd+echarts数据可视化demo

發(fā)布時(shí)間:2025/3/8 python 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python+xlrd+echarts数据可视化demo 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

    • 準(zhǔn)備工作
    • 數(shù)據(jù)處理
    • 頁面展示

準(zhǔn)備工作

導(dǎo)包+添加依賴

數(shù)據(jù)處理

處理一列評分?jǐn)?shù)據(jù)及其出現(xiàn)的次數(shù)

@app.route('/score') def score():# 打開文件workBook = xlrd.open_workbook('D:\\PycharmProjects\\flaskProject1\\templates\\xls\\豆瓣電影Top250.xls');score = [] # 評分num = [] # 每個(gè)評分所統(tǒng)計(jì)出的電影數(shù)量sheet1 = workBook.sheets()[0] # 獲得第1張sheet,索引從0開始score1 = sheet1.col_values(4) # 獲取評分信息score2 = Counter(score1)score3 = sorted(score2.items(), key=lambda dict1: score2[0])for item in score3:score.append(item[0])num.append(item[1])return render_template("score.html",score= score,num=num)

頁面展示

<!-- 為 ECharts 準(zhǔn)備一個(gè)具備大小(寬高)的 DOM --><div id="main" style="width: 100%;height:300px"></div><script type="text/javascript"> var dom = document.getElementById("main"); var myChart = echarts.init(dom); var app = {}; option = null; option = {color:['#3398DB'],tooltip: {trigger: 'axis',axisPointer: {type: 'shadow'}},grid: {left: '3%',right:'4%',bottom:'3%',containLabel:true},xAxis: {type: 'category',data:{{ score|tojson }}<!--['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','999']-->},yAxis: {type: 'value'},series: [{data: {{ num }},<!--[120, 20, 150, 80, 70, 110, 130,200],-->barWidth:'60%',type:'bar'}] }; ; if (option && typeof option === "object") {myChart.setOption(option, true); }</script>

總結(jié)

以上是生活随笔為你收集整理的python+xlrd+echarts数据可视化demo的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。