目前python,spark,scala十分火爆,于是我就利用爬蟲将獵聘上的招聘資訊進行了一下擷取,相比起來,獵聘上的職位數量還是很多的,3中技術類型以“python,spark,scala”作為關鍵詞,一共爬取了一萬多條資訊,爬取的主要資訊為:公司名稱,職位名稱,薪資,位址,職位資訊。最後将爬取後的資料,進行了簡單的處理,進行可視化。
資料擷取
爬蟲的寫法可以檢視https://blog.csdn.net/qq_36389249/article/details/87275723,資料爬取主要利用的是selenium,資料使用資料庫的方式進行存放
資料展示

上面3個圖分别代表的是,python,Scala,saprk的職位數量在城市在'北京', '上海', '廣州', '深圳', '南京', '杭州', '西安', '天津', '鄭州', '成都', '蘇州'的占比,可以很直覺在扇形中的看到,大都集中在北京和上海這兩個城市,找工作的各位看官,如果想擁有更多的機會,可以考慮下。
這個圖是在'北京', '上海', '廣州', '深圳', '南京', '杭州', '西安', '天津', '鄭州', '成都', '蘇州'這幾個城市中,釋出在獵聘上的資料職位數量資訊,還是很多的,至于數量最多的城市也就還是上海和北京。
還有就是我還做了python,spark,scala這三個的薪資的分析,首先是對python的薪資的分析,
{'面議': 879, '18-36萬': 140, '12-24萬': 135, '12-18萬': 128, '18-30萬': 123, '24-48萬': 80, '18-24萬': 76, '10-18萬': 66, '24-36萬': 53, '20-39萬': 37, '13-20萬': 28, '18-54萬': 28, '24-42萬': 26, '36-60萬': 26, '30-60萬': 24, '21-35萬': 23, '21-42萬': 23, '20-33萬': 22, '24-30萬': 22, '26-52萬': 22, '10-14萬': 21, '14-24萬': 20, '13-26萬': 20, '7-10萬': 18, '10-19萬': 17, '30-42萬': 17, '7-12萬': 17, '21-28萬': 16, '12-22萬': 16, '10-12萬': 16, '23-38萬': 15, '14-29萬': 15, '10-24萬': 15, '5-7萬': 15, '7-14萬': 14, '14-21萬': 14, '30-45萬': 13, '14-22萬': 13, '30-36萬': 13, '30-53萬': 12, '14-28萬': 12, '20-26萬': 12, '8-18萬': 12, '28-56萬': 12, '16-30萬': 11, '8-17萬': 10, '11-18萬': 10, '22-36萬': 10, '26-39萬': 10, '36-48萬': 10, '28-42萬': 10, '12-19萬': 10, '16-26萬': 9, '13-39萬': 9, '12-36萬': 9, '30-48萬': 9, '14-18萬': 8, '10-17萬': 8, '14-30萬': 8, '42-78萬': 8, '23-45萬': 8, '36-72萬': 8, '11-22萬': 8, '22-58萬': 8, '12-30萬': 8, '7-18萬': 7, '6-12萬': 7, '6-10萬': 7, '10-20萬': 7, '35-70萬': 7, '13-33萬': 7, '33-65萬': 7, '11-21萬': 6, '19-24萬': 6, '10-16萬': 6, '7-11萬': 6, '22-30萬': 6, '14-19萬': 6, '12-14萬': 6, '24-40萬': 6, '30-54萬': 5, '5-10萬': 5, '24-38萬': 5, '12-17萬': 5, '35-49萬': 5, '8-24萬': 5, '18-27萬': 5, '39-65萬': 5, '27-45萬': 5, '48-84萬': 5, '18-42萬': 4, '42-54萬': 4, '2-5萬': 4, '16-24萬': 4, '16-31萬': 4, '18-34萬': 4, '35-56萬': 4, '33-52萬': 4, '16-32萬': 4, '11-17萬': 4, '28-49萬': 4, '18-26萬': 4, '17-34萬': 4, '4-5萬': 4, '15-30萬': 4, '21-29萬': 4, '14-20萬': 4, '16-20萬': 4, '12-20萬': 4, '17-28萬': 4, '23-30萬': 4, '19-40萬': 4, '12-21萬': 4, '10-22萬': 4, '36-54萬': 4, '45-60萬': 4, '19-29萬': 4, '16-23萬': 3, '13-19萬': 3, '26-46萬': 3, '18-19萬': 3, '19-38萬': 3, '23-33萬': 3, '10-13萬': 3, '8-13萬': 3, '8-14萬': 3, '6-7萬': 3, '8-11萬': 3, '18-28萬': 3, '13-21萬': 3, '14-25萬': 3, '45-90萬': 3, '8-12萬': 3, '16-22萬': 3, '13-23萬': 3, '8-16萬': 3, '7-13萬': 3, '14-26萬': 3, '26-43萬': 3, '48-72萬': 3, '33-46萬': 3, '29-38萬': 3, '18-23萬': 3, '11-13萬': 3, '20-30萬': 3, '27-40萬': 3, '20-40萬': 3, '13-14萬': 3, '24-34萬': 2, '12-16萬': 2, '14-23萬': 2, '33-59萬': 2, '25-39萬': 2, '34-48萬': 2, '20-23萬': 2, '48-80萬': 2, '20-36萬': 2, '11-16萬': 2, '19-36萬': 2, '14-17萬': 2, '18-22萬': 2, '17-25萬': 2, '20-27萬': 2, '26-59萬': 2, '17-39萬': 2, '32-48萬': 2, '26-51萬': 2, '22-28萬': 2, '45-75萬': 2, '12-25萬': 2, '10-23萬': 2, '21-39萬': 2, '18-18萬': 2, '65-104萬': 2, '11-19萬': 2, '4-6萬': 2, '18-25萬': 2, '9-16萬': 2, '40-76萬': 2, '39-52萬': 2, '16-29萬': 2, '22-32萬': 2, '30-38萬': 2, '42-48萬': 2, '35-63萬': 2, '41-60萬': 2, '51-68萬': 2, '5-8萬': 2, '24-50萬': 2, '20-50萬': 2, '44-65萬': 2, '19-26萬': 2, '60-96萬': 2, '24-35萬': 2, '21-24萬': 2, '15-23萬': 2, '11-28萬': 2, '27-54萬': 2, '22-43萬': 2, '27-42萬': 2, '38-68萬': 2, '20-60萬': 2, '35-42萬': 2, '28-39萬': 1, '22-34萬': 1, '17-33萬': 1, '10-10萬': 1, '25-42萬': 1, '21-30萬': 1, '38-75萬': 1, '13-16萬': 1, '2-3萬': 1, '17-22萬': 1, '17-24萬': 1, '16-34萬': 1, '16-18萬': 1, '9-13萬': 1, '21-33萬': 1, '17-29萬': 1, '23-53萬': 1, '22-39萬': 1, '14-35萬': 1, '15-28萬': 1, '42-63萬': 1, '20-46萬': 1, '22-24萬': 1, '7-8萬': 1, '54-108萬': 1, '10-21萬': 1, '25-49萬': 1, '27-60萬': 1, '11-14萬': 1, '26-54萬': 1, '10-11萬': 1, '16-21萬': 1, '27-63萬': 1, '27-53萬': 1, '18-29萬': 1, '40-80萬': 1, '20-20萬': 1, '8-19萬': 1, '5-11萬': 1, '15-31萬': 1, '16-40萬': 1, '23-46萬': 1, '13-25萬': 1, '7-20萬': 1, '6-14萬': 1, '30-50萬': 1, '22-26萬': 1, '60-84萬': 1, '13-22萬': 1, '15-35萬': 1, '17-35萬': 1, '14-31萬': 1, '48-64萬': 1, '240-270萬': 1, '42-60萬': 1, '30-46萬': 1, '19-30萬': 1, '84-120萬': 1, '24-32萬': 1, '54-90萬': 1, '36-46萬': 1, '26-36萬': 1, '26-65萬': 1, '14-36萬': 1, '24-26萬': 1, '22-48萬': 1, '36-66萬': 1, '17-36萬': 1, '52-78萬': 1, '27-35萬': 1, '18-48萬': 1, '43-60萬': 1, '42-84萬': 1, '11-15萬': 1, '26-33萬': 1, '47-92萬': 1, '42-49萬': 1, '29-42萬': 1, '30-41萬': 1, '29-41萬': 1, '30-43萬': 1, '24-45萬': 1, '72-108萬': 1, '21-31萬': 1, '40-50萬': 1, '38-53萬': 1, '23-29萬': 1, '22-42萬': 1, '65-91萬': 1, '17-49萬': 1, '53-98萬': 1, '20-35萬': 1, '27-33萬': 1, '25-35萬': 1, '104-143萬': 1, '6-11萬': 1, '46-65萬': 1, '66-102萬': 1, '17-21萬': 1, '32-64萬': 1, '36-42萬': 1, '33-39萬': 1, '9-12萬': 1, '38-60萬': 1, '18-35萬': 1, '1-2萬': 1, '13-18萬': 1, '15-25萬': 1}
sprak的薪資分析:
{'面議': 624, '18-30萬': 106, '18-36萬': 85, '18-24萬': 73, '24-48萬': 69, '12-24萬': 62, '24-36萬': 47, '12-18萬': 47, '36-60萬': 38, '30-60萬': 37, '24-42萬': 32, '10-14萬': 31, '14-35萬': 29, '14-24萬': 27, '10-18萬': 26, '30-48萬': 26, '20-33萬': 24, '13-26萬': 16, '30-42萬': 15, '36-72萬': 15, '36-48萬': 15, '26-52萬': 15, '6-10萬': 14, '28-56萬': 13, '21-35萬': 13, '20-39萬': 12, '21-42萬': 12, '24-30萬': 10, '42-70萬': 10, '45-75萬': 10, '10-19萬': 10, '14-29萬': 9, '26-39萬': 9, '35-70萬': 9, '18-35萬': 9, '22-36萬': 8, '52-78萬': 8, '12-19萬': 8, '22-30萬': 8, '26-46萬': 8, '28-49萬': 8, '7-14萬': 7, '36-54萬': 7, '18-42萬': 7, '30-53萬': 7, '18-26萬': 7, '16-31萬': 7, '10-12萬': 7, '39-78萬': 6, '20-26萬': 6, '54-90萬': 6, '48-72萬': 6, '84-120萬': 6, '33-52萬': 6, '39-65萬': 6, '24-60萬': 6, '13-33萬': 6, '35-56萬': 6, '20-31萬': 6, '7-18萬': 6, '23-45萬': 5, '45-60萬': 5, '16-26萬': 5, '14-21萬': 5, '10-22萬': 5, '60-96萬': 5, '13-21萬': 5, '56-84萬': 5, '45-90萬': 5, '48-84萬': 5, '11-18萬': 5, '10-21萬': 5, '1-2萬': 5, '11-14萬': 5, '22-42萬': 5, '30-36萬': 4, '33-46萬': 4, '48-80萬': 4, '14-22萬': 4, '23-38萬': 4, '30-45萬': 4, '30-54萬': 4, '72-108萬': 4, '12-22萬': 4, '60-105萬': 4, '17-33萬': 4, '2-4萬': 4, '38-75萬': 4, '42-78萬': 4, '14-28萬': 4, '8-17萬': 4, '6-12萬': 4, '30-50萬': 4, '33-65萬': 4, '23-52萬': 4, '14-30萬': 3, '36-42萬': 3, '11-22萬': 3, '20-42萬': 3, '28-42萬': 3, '12-29萬': 3, '25-42萬': 3, '65-104萬': 3, '19-38萬': 3, '20-29萬': 3, '12-30萬': 3, '21-29萬': 3, '5-7萬': 3, '14-26萬': 3, '18-48萬': 3, '16-24萬': 3, '32-56萬': 3, '42-54萬': 3, '18-31萬': 3, '22-43萬': 3, '22-34萬': 3, '34-67萬': 3, '13-24萬': 3, '42-72萬': 3, '42-56萬': 3, '23-39萬': 3, '13-16萬': 3, '60-72萬': 3, '8-14萬': 3, '33-59萬': 3, '10-16萬': 3, '13-23萬': 3, '30-46萬': 2, '19-30萬': 2, '10-20萬': 2, '19-26萬': 2, '23-33萬': 2, '22-31萬': 2, '24-40萬': 2, '16-23萬': 2, '25-35萬': 2, '60-84萬': 2, '18-34萬': 2, '104-143萬': 2, '14-19萬': 2, '12-17萬': 2, '11-19萬': 2, '49-70萬': 2, '17-28萬': 2, '19-22萬': 2, '17-26萬': 2, '16-30萬': 2, '10-17萬': 2, '11-21萬': 2, '90-135萬': 2, '32-64萬': 2, '38-60萬': 2, '13-39萬': 2, '20-41萬': 2, '5-10萬': 2, '24-49萬': 2, '23-46萬': 2, '15-30萬': 2, '9-18萬': 2, '18-23萬': 2, '15-22萬': 2, '2-5萬': 2, '26-38萬': 2, '19-36萬': 2, '5-6萬': 2, '13-18萬': 2, '27-53萬': 2, '29-41萬': 2, '6-8萬': 2, '32-66萬': 2, '17-32萬': 2, '10-24萬': 2, '7-10萬': 2, '28-35萬': 1, '16-21萬': 1, '21-28萬': 1, '7-20萬': 1, '30-38萬': 1, '4-6萬': 1, '34-60萬': 1, '38-45萬': 1, '13-22萬': 1, '36-46萬': 1, '35-63萬': 1, '39-46萬': 1, '11-17萬': 1, '8-10萬': 1, '23-47萬': 1, '23-60萬': 1, '33-39萬': 1, '12-20萬': 1, '31-49萬': 1, '34-55萬': 1, '39-59萬': 1, '60-90萬': 1, '8-13萬': 1, '120000-180000萬': 1, '36-67萬': 1, '26-29萬': 1, '44-65萬': 1, '19-50萬': 1, '70-112萬': 1, '52-91萬': 1, '33-53萬': 1, '49-91萬': 1, '15-45萬': 1, '29-35萬': 1, '15-20萬': 1, '68-113萬': 1, '38-74萬': 1, '10-29萬': 1, '16-22萬': 1, '20-30萬': 1, '23-42萬': 1, '17-34萬': 1, '75-98萬': 1, '36-52萬': 1, '24-38萬': 1, '20-46萬': 1, '16-25萬': 1, '17-35萬': 1, '20-50萬': 1, '16-18萬': 1, '26-65萬': 1, '12-36萬': 1, '9-16萬': 1, '42-48萬': 1, '26-32萬': 1, '23-30萬': 1, '10-23萬': 1, '39-52萬': 1, '24-34萬': 1, '38-53萬': 1, '48-60萬': 1, '17-24萬': 1}
scala的薪資分析:
{'面議': 649, '18-36萬': 117, '24-48萬': 102, '18-30萬': 90, '12-18萬': 55, '24-36萬': 53, '12-24萬': 50, '10-18萬': 39, '18-24萬': 37, '30-60萬': 35, '36-60萬': 29, '30-42萬': 23, '24-42萬': 22, '21-35萬': 21, '30-48萬': 20, '10-14萬': 19, '23-45萬': 17, '28-56萬': 16, '22-36萬': 16, '21-42萬': 15, '16-30萬': 15, '26-52萬': 14, '36-72萬': 14, '20-33萬': 13, '20-39萬': 13, '12-22萬': 12, '10-12萬': 11, '48-72萬': 11, '36-54萬': 11, '14-28萬': 11, '7-14萬': 10, '14-30萬': 10, '30-36萬': 10, '13-20萬': 10, '30-54萬': 9, '22-30萬': 9, '24-60萬': 9, '14-24萬': 9, '13-26萬': 8, '24-30萬': 8, '28-49萬': 8, '48-84萬': 8, '28-42萬': 7, '65-104萬': 7, '33-65萬': 7, '12-30萬': 7, '10-19萬': 7, '39-52萬': 7, '19-30萬': 7, '25-49萬': 7, '21-49萬': 6, '20-26萬': 6, '14-29萬': 6, '42-70萬': 6, '42-84萬': 6, '35-56萬': 6, '17-33萬': 5, '25-35萬': 5, '36-48萬': 5, '14-22萬': 5, '38-60萬': 5, '35-70萬': 5, '18-48萬': 5, '35-49萬': 5, '39-65萬': 4, '30-53萬': 4, '22-34萬': 4, '60-96萬': 4, '12-36萬': 4, '18-23萬': 4, '18-35萬': 4, '33-46萬': 4, '14-21萬': 4, '8-17萬': 4, '38-75萬': 4, '16-31萬': 4, '10-24萬': 4, '21-28萬': 3, '52-78萬': 3, '54-90萬': 3, '19-50萬': 3, '42-60萬': 3, '14-35萬': 3, '6-10萬': 3, '45-75萬': 3, '56-84萬': 3, '39-78萬': 3, '2-4萬': 3, '16-24萬': 3, '26-36萬': 3, '16-26萬': 3, '22-42萬': 3, '26-46萬': 3, '60-84萬': 3, '8-12萬': 3, '7-12萬': 3, '56-98萬': 3, '48-56萬': 3, '20-36萬': 3, '14-25萬': 3, '38-53萬': 3, '24-41萬': 3, '12-19萬': 3, '18-26萬': 2, '42-72萬': 2, '17-25萬': 2, '18-25萬': 2, '13-21萬': 2, '42-78萬': 2, '11-21萬': 2, '16-32萬': 2, '7-10萬': 2, '72-108萬': 2, '16-22萬': 2, '9-16萬': 2, '26-39萬': 2, '42-56萬': 2, '20-29萬': 2, '32-64萬': 2, '23-39萬': 2, '23-38萬': 2, '18-42萬': 2, '24-34萬': 2, '29-58萬': 2, '8-14萬': 2, '19-36萬': 2, '22-43萬': 2, '15-30萬': 2, '19-42萬': 2, '12-14萬': 2, '10-17萬': 2, '26-51萬': 2, '60-105萬': 2, '60-72萬': 2, '30-38萬': 2, '20-28萬': 2, '45-90萬': 2, '10-13萬': 2, '17-24萬': 2, '30-40萬': 2, '28-36萬': 2, '54-108萬': 2, '10-16萬': 2, '42-80萬': 2, '27-53萬': 2, '11-22萬': 2, '10-20萬': 2, '72-96萬': 2, '48-54萬': 2, '18-28萬': 2, '40-80萬': 2, '12-29萬': 2, '60-90萬': 2, '48-80萬': 1, '15-22萬': 1, '46-78萬': 1, '108-132萬': 1, '13-22萬': 1, '36-66萬': 1, '17-26萬': 1, '26-29萬': 1, '11-28萬': 1, '16-23萬': 1, '27-45萬': 1, '25-42萬': 1, '32-44萬': 1, '58-72萬': 1, '2-5萬': 1, '5-6萬': 1, '8-13萬': 1, '40-64萬': 1, '11-14萬': 1, '16-21萬': 1, '17-30萬': 1, '20-52萬': 1, '28-63萬': 1, '30-43萬': 1, '20-60萬': 1, '30-68萬': 1, '20-38萬': 1, '84-112萬': 1, '23-46萬': 1, '33-52萬': 1, '34-48萬': 1, '29-45萬': 1, '22-39萬': 1, '64-112萬': 1, '13-24萬': 1, '17-28萬': 1, '19-26萬': 1, '21-29萬': 1, '17-23萬': 1, '48-96萬': 1, '8-18萬': 1, '7-13萬': 1, '12-23萬': 1, '6-8萬': 1, '46-65萬': 1, '30-45萬': 1, '64-96萬': 1, '42-66萬': 1, '22-29萬': 1, '56-88萬': 1, '21-56萬': 1, '18-18萬': 1, '20-42萬': 1, '31-48萬': 1, '39-70萬': 1, '45-99萬': 1, '28-70萬': 1, '24-32萬': 1, '15-23萬': 1, '29-48萬': 1, '17-34萬': 1, '29-63萬': 1, '24-38萬': 1, '17-27萬': 1, '42-48萬': 1, '12-20萬': 1, '59-78萬': 1, '14-26萬': 1, '32-48萬': 1, '31-50萬': 1, '75-120萬': 1, '13-23萬': 1, '42-49萬': 1, '54-78萬': 1, '36-42萬': 1, '4-6萬': 1, '28-50萬': 1, '26-65萬': 1, '45-68萬': 1, '49-70萬': 1, '4-7萬': 1, '11-18萬': 1, '43-68萬': 1, '5-7萬': 1, '23-29萬': 1, '22-56萬': 1, '12-17萬': 1, '10-22萬': 1, '4-4萬': 1, '56-75萬': 1, '38-45萬': 1, '4-10萬': 1, '13-33萬': 1, '23-33萬': 1, '34-38萬': 1, '18-34萬': 1, '19-38萬': 1, '22-32萬': 1}
可以看到這個薪資水準真的很恐怖。。。。。(4000塊的我瑟瑟發抖啊)。。。
這個薪資拿起來其實并不容易,看下有關職位資訊的詞雲就明白了。
3個詞雲圖分别是python,spark,scala的,可見開發經驗是十分重要的啊,不難發現,其實3-5年的就是大佬。是以我還是安心搬磚吧
while(1):
print("工作需要經驗")
print("找工作")
if("你有錢"):
break
print("睡醒了")
介紹下,上面個資料可視化的做法主要使用的為matplotlib的庫。至于說詞雲的話,那個很簡單,這個圖表的制作其實也不難,主要就是對人家庫的應用。都說用python就是站在巨人的肩膀上,我發現被人站在肩膀上,我在巨人的腳脖子上。
from collections import Counter
import pymysql
import re
from decimal import Decimal
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from matplotlib import collections, colors, transforms
from matplotlib.ticker import MultipleLocator,FormatStrFormatter
import numpy as np
import pandas as pd
import time#因為多個圖檔顯示加入了睡眠,友善資料觀察
import random
from pylab import *
global my_address
my_address = ['北京', '上海', '廣州', '深圳', '南京', '杭州', '西安', '天津', '鄭州', '成都', '蘇州']
def link_mysql():
config = {
'host':'127.0.0.1',
'user':'root',
'passwd':'1995104',
'port':8080,
'db':'lp',
'charset':'utf8',
}
#進行資料庫的連接配接
conn = pymysql.connect(**config)
#擷取遊标
cur = conn.cursor()
#資料讀取主要讀取内容為地區。
sql = "select address from python;"
global python_address
cur.execute(sql)
python_address = cur.fetchall()
sql = "select address from spark;"
global spark_address
cur.execute(sql)
spark_address = cur.fetchall()
# print(spark_address)
sql = "select address from scala;"
global scala_address
cur.execute(sql)
scala_address = cur.fetchall()
# print(scala_address)
#讀取資料擷取薪資的列資料
sql = 'select salary from python;'
global python_salary
cur.execute(sql)
python_salary = cur.fetchall()
sql = 'select salary from scala;'
global scala_salary
cur.execute(sql)
scala_salary = cur.fetchall()
sql = 'select salary from spark;'
global spark_salary
cur.execute(sql)
spark_salary = cur.fetchall()
# print(python_salary)
# print(scala_salary)
# print(spark_salary)
# 擷取區域内的工資情況,應為城市資料大多分布在北京 上海 深圳 廣州 杭州。
global python_address_salary
#擷取所有的工資資料
python_address_salary = {'北京':[], '上海':[], '廣州':[], '深圳':[],
'南京':[], '杭州':[], '西安':[], '天津':[],
'鄭州':[], '成都':[], '蘇州':[]}
sql = 'select * from python limit {},1;'
for i in range(0,len(python_address)):
cur.execute(sql.format(str(i)))
address_ = cur.fetchall()[0][3]
#利用正規表達式擷取地區
address_ = re.findall('[\u4e00-\u9fa5]*',address_)
# print(address)
cur.execute(sql.format(str(i)))
salary = cur.fetchall()[0][4]
# print(salary)
# address = re.findall('[\u4e00-\u9fa5]*',address)
#擷取對應地區的薪資内容
for j in range(0,len(my_address)):
if address_[0] == my_address[j]:
python_address_salary[my_address[j]].append(salary)
# print(python_address_salary)
#scala的資料内容
global scala_address_salary
scala_address_salary = {'北京': [], '上海': [], '廣州': [], '深圳': [],
'南京': [], '杭州': [], '西安': [], '天津': [],
'鄭州': [], '成都': [], '蘇州': []}
sql = 'select * from scala limit {},1;'
for i in range(0, len(scala_address)):
cur.execute(sql.format(str(i)))
#通過正規表達式擷取位址資料
address_ = cur.fetchall()[0][3]
address_ = re.findall('[\u4e00-\u9fa5]*', address_)
# print(address)
cur.execute(sql.format(str(i)))
salary = cur.fetchall()[0][4]
# print(salary)
# address = re.findall('[\u4e00-\u9fa5]*',address)
for j in range(0,len(my_address)):
if address_[0] == my_address[j]:
scala_address_salary[my_address[j]].append(salary)
# print(scala_address_salary)
#spark的資料展示
global spark_address_salary
spark_address_salary = {'北京': [], '上海': [], '廣州': [], '深圳': [],
'南京': [], '杭州': [], '西安': [], '天津': [],
'鄭州': [], '成都': [], '蘇州': []}
sql = 'select * from spark limit {},1;'
for i in range(0, len(spark_address)):
cur.execute(sql.format(str(i)))
address_ = cur.fetchall()[0][3]
address_ = re.findall('[\u4e00-\u9fa5]*', address_)
# print(address)
cur.execute(sql.format(str(i)))
salary = cur.fetchall()[0][4]
# address = re.findall('[\u4e00-\u9fa5]*',address)
for j in range(0,len(my_address)):
if address_[0] == my_address[j]:
spark_address_salary[my_address[j]].append(salary)
# print(spark_address_salary)
cur.close()
conn.close()
def get_address():
global scala_add
add = []
str_my = ''
#分析scala的主要職聘位址
for scala in scala_address:
scala = re.match('[\u4e00-\u9fa5]+',scala[0])
add.append(scala)
for m_scala in add:
if m_scala is not None:
# print(m_scala.group())
str_my = str_my+m_scala.group(0)+'\n'
# print(str_my)
new_txt = re.split('\W+',str_my)
result = Counter(new_txt)
global result_scala_address
result_scala_address = result.most_common(len(scala_address))
# print(result_scala_address)
str_my_b = ''
add.clear()
#分析python的位址
for python in python_address:
python = re.match('[\u4e00-\u9fa5]+',python[0])
add.append(python)
for m_python in add:
if m_python is not None:
str_my_b = str_my_b+m_python.group(0)+'\n'
new_txt = re.split('\W+',str_my_b)
result = Counter(new_txt)
global result_python_address
result_python_address = result.most_common(len(python_address))
# print(result_python_address)
str_my_a = ''
add.clear()
#分析spark的主要位址
for spark in spark_address:
spark = re.match('[\u4e00-\u9fa5]+',spark[0])
add.append(spark)
for m_spark in add:
if m_spark is not None:
str_my_a = str_my_a+m_spark.group(0)+'\n'
new_txt = re.split('\W+',str_my_a)
result = Counter(new_txt)
global result_spark_address
result_spark_address = result.most_common(len(spark_address))
# print(result_spark_address)
# b = 0
# for a in result_python_address:
# b = a[1]+b
# print(b)
#擷取百分比 百分比在繪制扇形圖時已經實作,注釋多餘程式
# global n_python,address
# n_python = []
# address = []
# for result in result_python_address:
# n_python.append(float(Decimal(result[1]/len(python_address)).quantize(Decimal('0.000'))))
# address.append(result[0])
# n_python = dict(zip(address,n_python))
# # print(n_python)
#
# address.clear()
# global n_scala
# n_scala = []
# for result in result_scala_address:
# n_scala.append(float(Decimal(result[1]/len(scala_address)).quantize(Decimal('0.000'))))
# address.append(result[0])
# n_scala = dict(zip(address,n_scala))
# # print(n_scala)
#
# address.clear()
# global n_spark
# n_spark = []
# for result in result_spark_address:
# n_spark.append(float(Decimal(result[1]/len(spark_address)).quantize(Decimal('0.000'))))
# address.append(result[0])
# n_spark = dict(zip(address,n_spark))
# print(n_spark)
#擷取薪資
def get_salary():
str_ = ''
global result_python_salary
for python in python_salary:
str_ = str_+python[0].replace('萬','')+' '
str_.replace('萬', ' ')
result_python_salary = str_
str_ = ''
global result_scala_salary
for scala in scala_salary:
str_ = str_+scala[0].replace('萬','')+' '
str_.replace('萬', ' ')
result_scala_salary = str_
str_ = ''
global result_spark_salary
for spark in spark_salary:
str_ = str_+spark[0].replace('萬','')+' '
str_.replace('面議','')
result_spark_salary = str_
new_txt = re.split(' ',result_python_salary)
result = Counter(new_txt)
result_python_salary = result.most_common(len(result_python_salary))
new_txt = re.split(' ', result_scala_salary)
result = Counter(new_txt)
result_scala_salary = result.most_common(len(result_scala_salary))
new_txt = re.split(' ', result_spark_salary)
result = Counter(new_txt)
result_spark_salary = result.most_common(len(result_spark_salary))
result1 = []
result2 = []
for result in result_python_salary:
if result[0] == "":
continue
else:
if (result[0] != '面議'):
result1.append(result[0] + '萬')
else:
result1.append(result[0])
result2.append(result[1])
result_python_salary = dict(zip(result1,result2))
result1 = []
result2 = []
for result in result_scala_salary:
if result[0] == "":
continue
else:
if (result[0] != '面議'):
result1.append(result[0] + '萬')
else:
result1.append(result[0])
result2.append(result[1])
result_scala_salary = dict(zip(result1,result2))
result1 = []
result2 = []
for result in result_spark_salary:
if result[0] == "":
continue
else:
if(result[0] != '面議'):
result1.append(result[0]+'萬')
else:
result1.append(result[0])
result2.append(result[1])
result_spark_salary = dict(zip(result1,result2))
#資料表示的内容位各個類型的工資的數量情況
print(result_python_salary)
print(result_scala_salary)
print(result_spark_salary)
# #
# print(len(result_python_salary))
# print(len(result_scala_salary))
# print(len(result_spark_salary))
def bar_show():
global x1#每個城市擁有的對應職位數量
x1 = [1]*len(my_address)
plt.rcParams['font.sans-serif'] = ['SimHei'] #用來顯示漢字
plt.rcParams['axes.unicode_minus'] = False #用來顯示負号
#繪制預設圖紙
plt.figure(1)#建立圖表
plt.figure(2)#建立圖表
plt.figure(3)#建立圖表
plt.subplots_adjust(hspace=2)
ax1 = plt.subplot(3,1,1)
ax2 = plt.subplot(3,1,2)
ax3 = plt.subplot(3,1,3)
#擷取城市名稱和數量
for result in result_python_address:
for i in range(0,len(my_address)-1):
if(result[0] == my_address[i]):
x1[i] = result[1]#對應擷取城市中的職位資料
# plt.figure(figsize=(10,8))
#x,y的标簽設定
plt.figure(1)
plt.sca(ax1)
ax1.spines['top'].set_visible(False)
ax1.spines['right'].set_visible(False)
plt.xlabel('城市名稱')
plt.ylabel('python職位數量/個')
plt.xticks(rotation=90,)
# plt.yticks(np.random.randint(0,max(x1),800))
plt.ylim((0,max(x1)+100))
plt.yticks(np.arange(0,max(x1)+100,500))
plt.legend()
plt.bar(my_address,x1,color='Red')
# plt.plot(address, x1)
autolabe(my_address,x1)
# plt.savefig('python.jpg')
global x2
x2 = [1]*len(my_address)
plt.figure(2)
plt.sca(ax2)
ax2.spines['top'].set_visible(False)
ax2.spines['right'].set_visible(False)
for result in result_scala_address:
for i in range(0,len(my_address)-1):
if(result[0] == my_address[i]):
x2[i] = result[1]#對應擷取城市中的職位資料
plt.xlabel('城市名稱')
plt.ylabel('scala職位數量/個')
plt.xticks(rotation=90,)
# plt.yticks(np.random.randint(0, max(x2), 800))
plt.ylim((0,max(x2)+100))
plt.yticks(np.arange(0,max(x2)+100,200))
plt.legend()
plt.bar(my_address,x2,color='GREEN')
# plt.plot(address,x2)
autolabe(my_address,x2)
# plt.savefig('scala.jpg')
global x3
x3 = [1]*len(my_address)
plt.figure(3)
plt.sca(ax3)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(False)
for result in result_spark_address:
for i in range(0,len(my_address)-1):
if(result[0] == my_address[i]):
x3[i] = result[1]#對應擷取城市中的職位資料
# x = x1+x2+x3
# x = {}.fromkeys(x).keys()
# print(len(x))
plt.xlabel('城市名稱')
plt.ylabel('spark職位數量/個')
plt.xticks(rotation=90,)
# plt.yticks(np.random.randint(0, max(x3), 800))
plt.ylim((0,max(x3)+100))
plt.yticks(np.arange(0,max(x3)+100,200))
plt.legend()
plt.bar(my_address,x3,color='BLUE')
# plt.plot(address, x3)
autolabe(my_address,x3)
plt.savefig('resulte_address.jpg')
plt.show()
def pie1_show():
# grids = GridSpec(3,1)
plt.figure(1,figsize=(8,12))#建立圖表
# plt.figure(2)#建立圖表
# plt.figure(3)#建立圖表
ax = plt.subplot()
plt.subplots_adjust(hspace=2)
plt.rcParams['font.sans-serif'] = ['SimHei'] #用來顯示漢字
plt.rcParams['axes.unicode_minus'] = False #用來顯示負号
plt.pie(x=x1, # 繪圖資料
labels=my_address, # 添加标簽
autopct='%.1f%%', # 設定百分比的格式,這裡保留一位小數
pctdistance=0.8, # 設定百分比标簽與圓心的距離
labeldistance=1.15, # 設定标簽與圓心的距離
startangle=180, # 設定餅圖的初始角度
radius=80, # 設定餅圖的半徑
counterclock=False, # 是否逆時針,這裡設定為順時針方向
wedgeprops={'linewidth': 1, 'edgecolor': 'black'}, # 設定餅圖内外邊界的屬性值
textprops={'fontsize': 15, 'color': 'w'}, # 設定文本标簽的屬性值
center=(0, 0), # 設定餅圖的原點
frame=1) # 是否顯示餅圖的圖框,這裡設定顯示
plt.axis('equal')
plt.legend(loc='upper left')
# plt.axis('off') #一行代碼實作去除坐标軸
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
plt.xticks([])
plt.yticks([])
plt.title('Python各城市占的職位數量比重',fontsize=20)
plt.savefig('pie1.jpg')
plt.show()
time.sleep(4)
def pie2_show():
plt.figure(1, figsize=(8, 12)) # 建立圖表
ax = plt.subplot()
plt.subplots_adjust(hspace=2)
plt.rcParams['font.sans-serif'] = ['SimHei'] #用來顯示漢字
plt.rcParams['axes.unicode_minus'] = False #用來顯示負号
# plt.pie(x2,labels=address,autopct='%1.0f%%',startangle=90,textprops={'fontsize':8,'color':'w'},
# pctdistance= 0.9,radius=0.8,center=(0.5,0.5))
# 控制x軸和y軸的範圍
plt.pie(x=x2, # 繪圖資料
labels=my_address, # 添加标簽
autopct='%.1f%%', # 設定百分比的格式,這裡保留一位小數
pctdistance=0.8, # 設定百分比标簽與圓心的距離
labeldistance=1.15, # 設定标簽與圓心的距離
startangle=180, # 設定餅圖的初始角度
radius=80, # 設定餅圖的半徑
counterclock=False, # 是否逆時針,這裡設定為順時針方向
wedgeprops={'linewidth': 1, 'edgecolor': 'black'}, # 設定餅圖内外邊界的屬性值
textprops={'fontsize': 15, 'color': 'w'}, # 設定文本标簽的屬性值
center=(0, 0), # 設定餅圖的原點
frame=1) # 是否顯示餅圖的圖框,這裡設定顯示
plt.axis('equal')
plt.legend(loc='upper left')
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
plt.xticks([])
plt.yticks([])
plt.title('Scala各城市占的職位數量比重',fontsize=20)
plt.savefig('pie2.jpg')
plt.show()
time.sleep(4)
def pie3_show():
plt.figure(1, figsize=(8, 12)) # 建立圖表
plt.subplots_adjust(hspace=2)
ax = plt.subplot()
plt.rcParams['font.sans-serif'] = ['SimHei'] #用來顯示漢字
plt.rcParams['axes.unicode_minus'] = False #用來顯示負号
plt.pie(x=x3, # 繪圖資料
labels=my_address, # 添加标簽
autopct='%.1f%%', # 設定百分比的格式,這裡保留一位小數
pctdistance=0.8, # 設定百分比标簽與圓心的距離
labeldistance=1.15, # 設定标簽與圓心的距離
startangle=180, # 設定餅圖的初始角度
radius=80, # 設定餅圖的半徑
counterclock=False, # 是否逆時針,這裡設定為順時針方向
wedgeprops={'linewidth': 1, 'edgecolor': 'black'}, # 設定餅圖内外邊界的屬性值
textprops={'fontsize': 15, 'color': 'w'}, # 設定文本标簽的屬性值
center=(0, 0), # 設定餅圖的原點
frame=1) # 是否顯示餅圖的圖框,這裡設定顯示
plt.axis('equal')
plt.legend(loc='upper left')
#去除坐标的周邊的線
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
plt.xticks([])
plt.yticks([])
plt.title('Spark各城市占的職位數量比重',fontsize=20)
plt.savefig('pie3.jpg')
plt.show()
#設定顯示柱子上的資料
def autolabe(x,y):
for _x, _y in zip(x, y):
plt.text(_x, _y, '%d' % _y,
ha='center', va='bottom', size=8
)
def bar_python():
# plt.figure(figsize=(19,13))
fig,ax = plt.subplots()
plt.rcParams['font.sans-serif'] = ['SimHei'] #用來顯示漢字
plt.rcParams['axes.unicode_minus'] = False #用來顯示負号
#擷取Python中的薪資的數量
salary = [salary for salary in result_python_salary.values()]
my_type = [my_type for my_type in result_python_salary.keys()]
# y_pos = np.arange(len(my_type))
# perfomance = 3+10*np.random.rand(len(my_type))
# error = np.random.rand(len(my_type))
# ax.tick_params(which=len(my_type))
ax.tick_params(axis = "y",width = (max(salary)+20),pad = 3)#設定坐标軸寬度
ax.tick_params(axis = "x",width = (len(my_type)+20),pad = 3) #設定坐标軸高度
# ax.barh(y_pos,perfomance,xerr=error,align='center',color="BLUE",ecolor='GREEN')
# ax.set_yticks(y_pos)
# ax.set_yticklabels(my_type)
# ax.invert_yaxis()
plt.ylim(0,(max(salary)+20))
# plt.xlim(0,20)
plt.xticks(rotation=90,)
# autolabe(my_type,salary)
ax.plot(my_type,salary,'o')
for label in ax.get_xticklabels():
label.set_visible(False)
for label in ax.get_xticklabels()[::20]:
label.set_visible(True)
# plt.savefig("{}.jpg".format(date), dpi=500)
plt.savefig("python_bar.jpg",dpi=500)
plt.show()
if __name__ == '__main__':
link_mysql()
get_address()
get_salary()
bar_show()
pie1_show()
pie2_show()
pie3_show()
bar_python()