用Python分析BOSS直聘的薪资数据,牛年找工作有方向了!
↑ 关注 + 星标 ,每天学Python新技能
后台回复【大礼包】送你Python自学大礼包
新年开始了,不少小伙伴有找新工作的意向,今天我们来看看招聘网站上,关于Python的工作,薪资状况是怎样的呢!
数据来源
数据来源于BOSS直聘,说实话,现在的招聘网站,做的比较好的还是BOSS直聘,其相关的数据、报告等都是比较有代表性的。今天我们就来看看相关的数据吧!
数据获取
BOSS直聘上有这么一个接口,可以很好的获取当前不同岗位,不同城市的薪资水平
https://www.zhipin.com/wapi/zpboss/h5/marketpay/statistics.json
可以很方便的获取比较详细的薪资数据
import requests
headers = {'accept': 'application/json, text/plain, */*',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36'}
querystring = {"positionId":"100109","industryId":"0","cityId":"0","companySize":"0","financingStage":"0","experienceCode":"0"}
job_statics_url = 'https://www.zhipin.com/wapi/zpboss/h5/marketpay/statistics.json'
job_statics_data = requests.get(job_statics_url, params=querystring, headers=headers)
这样,就可以获取到我们想要的 json 数据了
下面我们就可以简单的来分析下相关的薪资数据了
数据分析
薪资分位值
在我们获取到的数据当中,就有分位值的数据,可以方便的获取
job_statics_data_json = job_staticis_data.json()
job_statics_data_json['zpData']['salaryByPoints']
接下来就可以整理横纵坐标轴了
statics_x = []
statics_y = []
for i in job_statics_data_json['zpData']['salaryByPoints']:
statics_x.append(i['name'] + '\n' + i['title'])
statics_y.append(i['salary'])
下面开始作图
import pyecharts.options as opts
from pyecharts.charts import Line, Bar, Pie, Calendar, WordCloud
from pyecharts.commons.utils import JsCode
from pyecharts.globals import SymbolType
x_data = statics_x
y_data = statics_y
background_color_js = (
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
"[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
)
area_color_js = (
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
"[{offset: 0, color: '#eb64fb'}, {offset: 1, color: '#3fbbff0d'}], false)"
)
c_line = (
Line(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)))
.add_xaxis(xaxis_data=x_data)
.add_yaxis(
series_name="薪资",
y_axis=y_data,
is_smooth=True,
is_symbol_show=True,
symbol="circle",
symbol_size=6,
linestyle_opts=opts.LineStyleOpts(color="#fff"),
label_opts=opts.LabelOpts(is_show=True, position="top", color="white"),
itemstyle_opts=opts.ItemStyleOpts(
color="red", border_color="#fff", border_width=3
),
tooltip_opts=opts.TooltipOpts(is_show=False),
areastyle_opts=opts.AreaStyleOpts(color=JsCode(area_color_js), opacity=1),
)
.set_global_opts(
title_opts=opts.TitleOpts(
title="收入分位",
pos_bottom="5%",
pos_left="center",
title_textstyle_opts=opts.TextStyleOpts(color="#fff", font_size=16),
),
xaxis_opts=opts.AxisOpts(
type_="category",
boundary_gap=False,
axislabel_opts=opts.LabelOpts(margin=30, color="#ffffff63"),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(
is_show=True,
length=25,
linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),
),
splitline_opts=opts.SplitLineOpts(
is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")
),
),
yaxis_opts=opts.AxisOpts(
type_="value",
position="right",
axislabel_opts=opts.LabelOpts(margin=20, color="#ffffff63"),
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(width=2, color="#fff")
),
axistick_opts=opts.AxisTickOpts(
is_show=True,
length=15,
linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),
),
splitline_opts=opts.SplitLineOpts(
is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")
),
),
legend_opts=opts.LegendOpts(is_show=False),
)
)
可以得到一个还不错的折线图
可以看到,业内Python的薪资水平,大部分应该都处于1万左右,这个薪资水平其实并不太高,看来纯的Python岗位并不太吃香,要想获得更高的薪资,还是需要有更多的技能傍身!
薪资区间分布
下面再来看看薪资的分布情况
statics_x = []
statics_y = []
for i in job_statics_data_json['zpData']['salaryByDistributed']:
statics_y.append(i['percent'])
statics_x.append(i['salaryRange'])
def bar_chart(x, y) -> Bar:
background_color_js = (
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
"[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
)
c = (
Bar(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)))
#Bar()
.add_xaxis(x)
# .add_xaxis(searchcount.index.tolist()[:10])
.reversal_axis()
.add_yaxis("", y,
label_opts=opts.LabelOpts(position='inside', formatter="{c}%"),
color='plum', category_gap="60%"
)
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30, formatter="{value}%"),
axisline_opts=opts.AxisLineOpts(is_show=False),),
yaxis_opts=opts.AxisOpts(
axislabel_opts=opts.LabelOpts(is_show=True),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(
is_show=True,
length=25,
linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),
),)
)
.set_series_opts(
itemstyle_opts={
"normal": {
"color": JsCode("""new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(255,100,97,.5)'
}, {
offset: 1,
color: 'rgba(221,160,221)'
}], false)"""),
"barBorderRadius": [30, 30, 30, 30],
"shadowColor": 'rgb(0, 160, 221)',
}}
)
)
return c
来看看薪资分布情况
可以看到,15K以上的薪资还是占了16%以上,而占比最大的薪资区间则是7-9K
工作年限薪资分布
下面我们继续来看看薪资水平和工作年限之间的关系
statics_x = []
statics_y = []
for i in job_statics_data_json['zpData']['salaryByWorkExp']:
statics_y.append(i['percent'])
statics_x.append(i['workExp'] + ':' + str(i['aveSalary']))
background_color_js = (
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
"[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
)
c = (
Pie(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)))
.add(
"",
list(zip(statics_x, statics_y)),
radius=["40%", "55%"],
label_opts=opts.LabelOpts(
position="outside",
formatter="{a|job}{abg|}\n{hr|}\n {b|{b}: }{per|{d}%} ",
background_color="#eee",
border_color="#aaa",
border_width=1,
border_radius=4,
rich={
"a": {"color": "#999", "lineHeight": 22, "align": "center"},
"abg": {
"backgroundColor": "#e3e3e3",
"width": "100%",
"align": "right",
"height": 22,
"borderRadius": [4, 4, 0, 0],
},
"hr": {
"borderColor": "#aaa",
"width": "100%",
"borderWidth": 0.5,
"height": 0,
},
"b": {"fontSize": 16, "lineHeight": 33},
"per": {
"color": "#eee",
"backgroundColor": "#334455",
"padding": [2, 4],
"borderRadius": 2,
},
},
),
)
.set_global_opts(title_opts=opts.TitleOpts(title=""))
)
可以看到,下面的图片还是比较直观的
1-3年的应聘者还是最多的,占比达到了50%+,这个经验段,确实是职场的主力军了!
任职年龄分布
职场的年龄也是一个热点话题,35+岁的程序员们,总是一言难尽啊
statics_x = []
statics_y = []
for i in job_statics_data_json['zpData']['salaryByAge']:
statics_x.append(i['ageRange'])
statics_y.append(i['people'])
def bar_chart_age(x, y) -> Bar:
background_color_js = (
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
"[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
)
c = (
Bar(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)))
#Bar()
.add_xaxis(x)
# .add_xaxis(searchcount.index.tolist()[:10])
# .reversal_axis()
.add_yaxis("", y,
label_opts=opts.LabelOpts(position='inside', formatter="{c}"),
color='plum', category_gap="60%"
)
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30, formatter="{value}"),
axisline_opts=opts.AxisLineOpts(is_show=False),),
yaxis_opts=opts.AxisOpts(
axislabel_opts=opts.LabelOpts(is_show=True),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(
is_show=True,
length=25,
linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),
),)
)
.set_series_opts(
itemstyle_opts={
"normal": {
"color": JsCode("""new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(255,100,97,.5)'
}, {
offset: 1,
color: 'rgba(221,160,221)'
}], false)"""),
"barBorderRadius": [30, 30, 30, 30],
"shadowColor": 'rgb(0, 160, 221)',
}}
)
)
return c
数据很能说明问题
可以看到,35岁以下的占据了绝大多数,可想而知,35+的程序员生存状况是多么的糟糕!
月薪环比变化
我们通过每个月的薪资变化,来看看哪个月找工作比较有机会获得更高的薪资呢
statics_x = []
statics_y = []
for i in job_statics_data_json['zpData']['salaryByMonth']:
statics_x.append(i['year'] + '-' + i['month'])
statics_y.append(i['monthAveSalary'])
x_data = statics_x
y_data = statics_y
每月薪资变化
可以看到,去年2月份的薪资水平是最高的,之后一路下滑,再之后就基本趋于稳定了,7-8K这个平均水平
薪资城市分布
通过Pycharts画地图还是蛮方便的
statics_x = []
statics_y = []
for i in job_statics_data_json['zpData']['salaryByCity']:
if i['cityList']:
statics_x.append(i['cityList'][0]['cityAveMonthSalary'])
statics_y.append(i['provinceName'])
c = (
Map()
.add("全国薪资", [list(z) for z in zip(statics_y, statics_x)], "china")
.set_global_opts(
title_opts=opts.TitleOpts(title=""),
visualmap_opts=opts.VisualMapOpts(max_=15000, min_=6000),
)
)
全国薪资分布
好了,今天的分享就到这里了,希望对大家有所帮助!
源码获取