作者 | JackTian
来源 | 杰哥的IT之旅
经常会收到读者关于一系列咨询运维方面的事情,比如:运维到底是做什么的呀?运维的薪资水平/ 待遇怎么样呢?能帮忙看下这个岗位的招聘需要对于小白来说,能否胜任的了呢?等等。
杰哥带着一种好奇心的想法,结合自身的工作经验与业界全国关于招聘运维工程师的岗位做一个初步型的分析,我的一位好朋友帮我爬取了 13966 条关于运维的招聘信息,看看有哪些数据存在相关差异化。主要包括内容:
热门行业的用人需求 Top10
热门城市的岗位数量 Top10
岗位的省份分布
不同公司规模的用人情况
排名前 10 的岗位的平均薪资
岗位对学历的要求
运维岗位需求的词云图分布
对于本文的叙述,我们分以下三步为大家讲解。
爬虫部分
数据清洗
数据可视化及分析
爬虫部分
本文主要爬取的是 51job 上面,关于运维相关岗位的数据,网站解析主要使用的是Xpath,数据清洗用的是 Pandas 库,而可视化主要使用的是 Pyecharts 库。
相关注释均已在代码中注明,为方便阅读,这里只展示部分代码,完整代码可查看文末部分进行获取。
# 1、岗位名称
job_name = dom.xpath('//div[@class="dw_table"]/div[@class="el"]//p/span/a[@target="_blank"]/@title')
# 2、公司名称
company_name = dom.xpath('//div[@class="dw_table"]/div[@class="el"]/span[@class="t2"]/a[@target="_blank"]/@title')
# 3、工作地点
address = dom.xpath('//div[@class="dw_table"]/div[@class="el"]/span[@class="t3"]/text()')
# 4、工资
salary_mid = dom.xpath('//div[@class="dw_table"]/div[@class="el"]/span[@class="t4"]')
salary = [i.text for i in salary_mid]
# 5、发布日期
release_time = dom.xpath('//div[@class="dw_table"]/div[@class="el"]/span[@class="t5"]/text()')
# 6、获取二级网址url
deep_url = dom.xpath('//div[@class="dw_table"]/div[@class="el"]//p/span/a[@target="_blank"]/@href')
# 7、爬取经验、学历信息,先合在一个字段里面,以后再做数据清洗。命名为random_all
random_all = dom_test.xpath('//div[@class="tHeader tHjob"]//div[@class="cn"]/p[@class="msg ltype"]/text()')
# 8、岗位描述信息
job_describe = dom_test.xpath('//div[@class="tBorderTop_box"]//div[@class="bmsg job_msg inbox"]/p/text()')
# 9、公司类型
company_type = dom_test.xpath('//div[@class="tCompany_sidebar"]//div[@class="com_tag"]/p[1]/@title')
# 10、公司规模(人数)
company_size = dom_test.xpath('//div[@class="tCompany_sidebar"]//div[@class="com_tag"]/p[2]/@title')
# 11、所属行业(公司)
industry = dom_test.xpath('//div[@class="tCompany_sidebar"]//div[@class="com_tag"]/p[3]/@title')
数据清洗
1)读取数据
# 下面使用到的相关库,在这里展示一下
import pandas as pd
import numpy as np
import re
import jieba
df = pd.read_csv("only_yun_wei.csv",encoding="gbk",header=None)
df.head()
2)为数据设置新的行、列索引
# 为数据框指定行索引
df.index = range(len(df))
# 为数据框指定列索引
df.columns = ["岗位名","公司名","工作地点","工资","发布日期","经验与学历","公司类型","公司规模","行业","工作描述"]
df.head()
3)去重处理
# 去重之前的记录数
print("去重之前的记录数",df.shape)
# 记录去重
df.drop_duplicates(subset=["公司名","岗位名","工作地点"],inplace=True)
# 去重之后的记录数
print("去重之后的记录数",df.shape)
4)对岗位名字段的处理
# ① 岗位字段名的探索
df["岗位名"].value_counts()
df["岗位名"] = df["岗位名"].apply(lambda x:x.lower())
# ② 构造想要分析的目标岗位,做一个数据筛选
df.shape
target_job = ['运维','Linux运维','运维开发','devOps','应用运维','系统运维','数据库运维','运维安全','网络运维','桌面运维']
index = [df["岗位名"].str.count(i) for i in target_job]
index = np.array(index).sum(axis=0) > 0
job_info = df[index]
job_info.shape
job_list = ['linux运维','运维开发','devOps','应用运维','系统运维','数据库运维'
,'运维安全','网络运维','桌面运维','it运维','软件运维','运维工程师']
job_list = np.array(job_list)
def rename(x=None,job_list=job_list):
index = [i in x for i in job_list]
if sum(index) > 0:
return job_list[index][0]
else:
return x
job_info["岗位名"] = job_info["岗位名"].apply(rename)
job_info["岗位名"].value_counts()[:10]
5)工资字段的处理
job_info["工资"].str[-1].value_counts()
job_info["工资"].str[-3].value_counts()
index1 = job_info["工资"].str[-1].isin(["年","月"])
index2 = job_info["工资"].str[-3].isin(["万","千"])
job_info = job_info[index1 & index2]
job_info["工资"].str[-3:].value_counts()
def get_money_max_min(x):
try:
if x[-3] == "万":
z = [float(i)*10000 for i in re.findall("[0-9]+\.?[0-9]*",x)]
elif x[-3] == "千":
z = [float(i) * 1000 for i in re.findall("[0-9]+\.?[0-9]*", x)]
if x[-1] == "年":
z = [i/12 for i in z]
return z
except:
return x
salary = job_info["工资"].apply(get_money_max_min)
job_info["最低工资"] = salary.str[0]
job_info["最高工资"] = salary.str[1]
job_info["工资水平"] = job_info[["最低工资","最高工资"]].mean(axis=1)
6)工作地点字段的处理
address_list = ['北京', '上海', '广州', '深圳', '杭州', '苏州', '长沙',
'武汉', '天津', '成都', '西安', '东莞', '合肥', '佛山',
'宁波', '南京', '重庆', '长春', '郑州', '常州', '福州',
'沈阳', '济南', '宁波', '厦门', '贵州', '珠海', '青岛',
'中山', '大连','昆山',"惠州","哈尔滨","昆明","南昌","无锡"]
address_list = np.array(address_list)
def rename(x=None,address_list=address_list):
index = [i in x for i in address_list]
if sum(index) > 0:
return address_list[index][0]
else:
return x
job_info["工作地点"] = job_info["工作地点"].apply(rename)
job_info["工作地点"].value_counts()
7)公司类型字段的处理
job_info.loc[job_info["公司类型"].apply(lambda x:len(x)
关注
打赏
立即登录/注册


微信扫码登录