<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ![](http://imgs.bizha.top//86af4f43b3905ceb2f27e2ebd2da01dd) 前面兩篇用`MongoDB`數據庫進行了代理池維護,這篇用這個數據庫進行可視化。數據庫`Documents`格式為: ```json { "_id": { "$oid": "5ea99e09c1e6fefaa9e4531a" }, "https": "Socks4://119.146.131.247:8080", "Location": "中國廣東梅州", "AddTime": "2020年04月29日 23時32分25秒", "LastUpdate": "2020年04月30日 15時43分16秒" } ``` 對`Location`進行數據分析 ![](http://imgs.bizha.top//4718cf2d87d3dabe867d61abb1c3332d) ``` xaxis = list(set(LocationList )) yaxis = [] for x in xaxis: y = xaxis.count(x) yaxis.append(y) ``` ### 一、生成柱狀圖 LocationList = [Proxies['Location'] for Proxies in ProxiesList] 柱狀圖X軸為`Location`,Y軸為數量. ![](http://imgs.bizha.top//9adcff630d96e5a40de4a849cc0be04b) 柱狀圖太密集,提取`Location`國家再次生成柱狀圖。 ![](http://imgs.bizha.top//753a1fc20b885822445b2b1020184b47) 再次生成(完整代碼) ``` # -*- coding: utf-8 -*- """ Created on Thu Apr 30 16:06:15 2020 @author: Fuwenyue """ from pyecharts.charts import Bar import pymongo myclient = pymongo.MongoClient('mongodb://fuwenyue:pass4Top@ds049446.mlab.com:49446/proxy',retryWrites='false') mydb = myclient['proxy'] ProxiesCol = mydb['socks'] ProxiesList = ProxiesCol.find({},{ "_id": 0, "Location": 1}).sort('update',-1) ProxiesList = [i for i in ProxiesList] LocationList = [Proxies['Location'] for Proxies in ProxiesList] LocationList = [Location[0:2] for Location in LocationList] dic = {} xaxis = list(set(LocationList)) for x in xaxis: y = LocationList.count(x) dic[x] = y yaxis = [dic[x] for x in xaxis] bar = ( Bar() .add_xaxis(xaxis) .add_yaxis("Socks", yaxis) ) #bar.render_notebook() ``` ![](http://imgs.bizha.top//17cb893d0c0ed1a325acb9eb2e171cc4) **效果并不好,再次優化,按數量排序** dict 轉 tuple,list ``` d = {'s':2,'e':5,'g':6,'j':7,'m':8,'a':10} t = tuple(d.items()) print(t) >>(('s', 2), ('e', 5), ('g', 6), ('j', 7), ('m', 8), ('a', 10)) l = list(t) print(l) >>[('s', 2), ('e', 5), ('g', 6), ('j', 7), ('m', 8), ('a', 10)] ``` list tuple排序 ``` l = [('s',2),('e',5),('g',6),('j',7),('m',8),('a',10)] sorted_l=sorted(l,key=lambda t:t[0]) print(sorted_l) >>[('a', 10), ('e', 5), ('g', 6), ('j', 7), ('m', 8), ('s', 2)] l = [('s',2),('e',5),('g',6),('j',7),('m',8),('a',10)] sorted_l=sorted(l,key=lambda t:t[1],reverse=False) print(sorted_l) >>[('s', 2), ('e', 5), ('g', 6), ('j', 7), ('m', 8), ('a', 10)] ``` 排序柱狀圖 ![](http://imgs.bizha.top//1e741b7588edebcf32b11ca8b3615f9b) ``` # -*- coding: utf-8 -*- """ Created on Thu Apr 30 16:06:15 2020 @author: Fuwenyue """ from pyecharts.charts import Bar import pymongo myclient = pymongo.MongoClient('mongodb://fuwenyue:pass4Top@ds049446.mlab.com:49446/proxy',retryWrites='false') mydb = myclient['proxy'] ProxiesCol = mydb['socks'] ProxiesList = ProxiesCol.find({},{ "_id": 0, "Location": 1}).sort('update',-1) ProxiesList = [i for i in ProxiesList] LocationList = [Proxies['Location'] for Proxies in ProxiesList] LocationList = [Location[0:2] for Location in LocationList] dic = {} xaxis = list(set(LocationList)) for x in xaxis: y = LocationList.count(x) dic[x] = y l = list(tuple(dic.items())) sorted_l = sorted(l,key=lambda t:t[1],reverse=True) xaxis = [x[0] for x in sorted_l] yaxis = [x[1] for x in sorted_l] bar = ( Bar() .add_xaxis(xaxis) .add_yaxis("Socks", yaxis) ) #bar.render_notebook() ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看