python数据分析小案例:把招聘数据做可视化处理~

前言

大家早好、午好、晚好吖~

在前一章:python在线采集聘用数据,这不得学会找份新工作~

我们讲了如何采集zhaopin网站数据,现在~我们来对数据进行可视化操作

下面,我们直接上代码~

目录(可点击自己想去得地方哦~😋)

代码提供者:青灯教育-自游老师

代码

import pandas as pd
from pyecharts.charts import *
from pyecharts import options as opts
import re
from pyecharts.globals import ThemeType
from pyecharts.commons.utils import JsCode
# 读取数据
df = pd.read_csv("招聘数据.csv")
df.head()
df.info()
df['薪资'].unique()
df['bottom']=df['薪资'].str.extract('^(\d+).*')
df['top']=df['薪资'].str.extract('^.*?-(\d+).*')
df['top'].fillna(df['bottom'],inplace=True)

df['commision_pct']=df['薪资'].str.extract('^.*?·(\d{2})薪')
df['commision_pct'].fillna(12,inplace=True)
df['commision_pct']=df['commision_pct'].astype('float64')
df['commision_pct']=df['commision_pct']/12

df.dropna(inplace=True)

df['bottom'] = df['bottom'].astype('int64')
df['top'] = df['top'].astype('int64')
df['平均薪资'] = (df['bottom']+df['top'])/2*df['commision_pct']
df['平均薪资'] = df['平均薪资'].astype('int64')

df.head()
df['薪资'] = df['薪资'].apply(lambda x:re.sub('.*千/月', '0.3-0.7万/月', x))
df["薪资"].unique()
df['bottom'] = df['薪资'].str.extract('^(.*?)-.*?')
df['top'] = df['薪资'].str.extract('^.*?-(\d\.\d|\d)')
df.dropna(inplace=True)
df['bottom'] = df['bottom'].astype('float64')
df['top'] = df['top'].astype('float64')
df['平均薪资'] = (df['bottom']+df['top'])/2 * 10
df.head()

完整可视化代码可加Q裙:832157862

mean = df.groupby('学历')['平均薪资'].mean().sort_values()
x = mean.index.tolist()
y = mean.values.tolist()
c = (
    Bar()
    .add_xaxis(x)
    .add_yaxis(
        "学历",
        y
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="不同学历的平均薪资"),datazoom_opts=opts.DataZoomOpts())
    .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
)
c.render_notebook()
 完整可视化代码可加Q裙:832157862
color_js = """new echarts.graphic.LinearGradient(0, 1, 0, 0,
    [{offset: 0, color: '#63e6be'}, {offset: 1, color: '#0b7285'}], false)"""

color_js1 = """new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: '#ed1941'
                        }, {
                            offset: 1,
                            color: '#009ad6'
                        }], false)"""

dq = df.groupby('城市')['职位'].count().to_frame('数量').sort_values(by='数量',ascending=False).reset_index()
x_data = dq['城市'].values.tolist()[:20]
y_data = dq['数量'].values.tolist()[:20]
b1 = (
        Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK,bg_color=JsCode(color_js1),width='1000px',height='600px'))
        .add_xaxis(x_data)
        .add_yaxis('',
                   y_data ,
                   category_gap="50%",
                   label_opts=opts.LabelOpts(
                        font_size=12,
                        color='yellow',
                        font_weight='bold', 
                        font_family='monospace',
                        position='insideTop',  
                        formatter = '{b}\n{c}'  
                    ),
                  )
        .set_series_opts(
            itemstyle_opts={
                "normal": {
                    "color": JsCode(color_js),
                    "barBorderRadius": [15, 15, 0, 0],
                    "shadowColor": "rgb(0, 160, 221)",
                }
            }
        )
        .set_global_opts(
            title_opts=opts.TitleOpts(title='招 聘 数 量 前 20 的 城 市 区 域',
                                       title_textstyle_opts=opts.TextStyleOpts(color="yellow"),
                                       pos_top='7%',pos_left = 'center'
                                     ),
            legend_opts=opts.LegendOpts(is_show=False),
            xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),
            yaxis_opts=opts.AxisOpts(name="",
                                     name_location='middle',
                                     name_gap=40,
                                     name_textstyle_opts=opts.TextStyleOpts(font_size=16)),
                         datazoom_opts=[opts.DataZoomOpts(range_start=1,range_end=50)]
                        )

    )
b1.render_notebook()

 完整可视化代码可加Q裙:832157862
boss = df['学历'].value_counts()
x = boss.index.tolist()
y = boss.values.tolist()
data_pair = [list(z) for z in zip(x, y)]
c = (
    Pie(init_opts=opts.InitOpts(width="1000px", height="600px", bg_color="#2c343c"))
    .add(
        series_name="学历需求占比",
        data_pair=data_pair,
        label_opts=opts.LabelOpts(is_show=False, position="center", color="rgba(255, 255, 255, 0.3)"),
    )
    .set_series_opts(
        tooltip_opts=opts.TooltipOpts(
            trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"
        ),
        label_opts=opts.LabelOpts(color="rgba(255, 255, 255, 0.3)"),
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title="学历需求占比",
            pos_left="center",
            pos_top="20",
            title_textstyle_opts=opts.TextStyleOpts(color="#fff"),
        ),
        legend_opts=opts.LegendOpts(is_show=False),
    )
    .set_colors(["#D53A35", "#334B5C", "#61A0A8", "#D48265", "#749F83"])
)
c.render_notebook()

 完整可视化代码可加Q裙:832157862
boss = df['经验'].value_counts()
x = boss.index.tolist()
y = boss.values.tolist()
data_pair = [list(z) for z in zip(x, y)]
c = (
    Pie(init_opts=opts.InitOpts(width="1000px", height="600px", bg_color="#2c343c"))
    .add(
        series_name="经验需求占比",
        data_pair=data_pair,
        label_opts=opts.LabelOpts(is_show=False, position="center", color="rgba(255, 255, 255, 0.3)"),
    )
    .set_series_opts(
        tooltip_opts=opts.TooltipOpts(
            trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"
        ),
        label_opts=opts.LabelOpts(color="rgba(255, 255, 255, 0.3)"),
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title="经验需求占比",
            pos_left="center",
            pos_top="20",
            title_textstyle_opts=opts.TextStyleOpts(color="#fff"),
        ),
        legend_opts=opts.LegendOpts(is_show=False),
    )
    .set_colors(["#D53A35", "#334B5C", "#61A0A8", "#D48265", "#749F83"])
)
c.render_notebook()

 完整可视化代码可加Q裙:832157862
boss = df['公司领域'].value_counts()
x = boss.index.tolist()
y = boss.values.tolist()
data_pair = [list(z) for z in zip(x, y)]
c = (
    Pie(init_opts=opts.InitOpts(width="1000px", height="600px", bg_color="#2c343c"))
    .add(
        series_name="公司领域占比",
        data_pair=data_pair,
        label_opts=opts.LabelOpts(is_show=False, position="center", color="rgba(255, 255, 255, 0.3)"),
    )
    .set_series_opts(
        tooltip_opts=opts.TooltipOpts(
            trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"
        ),
        label_opts=opts.LabelOpts(color="rgba(255, 255, 255, 0.3)"),
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title="公司领域占比",
            pos_left="center",
            pos_top="20",
            title_textstyle_opts=opts.TextStyleOpts(color="#fff"),
        ),
        legend_opts=opts.LegendOpts(is_show=False),
    )
    .set_colors(["#D53A35", "#334B5C", "#61A0A8", "#D48265", "#749F83"])
)
c.render_notebook()
from pyecharts import options as opts
from pyecharts.charts import Pie
from pyecharts.faker import Faker
boss = df['经验'].value_counts()
x = boss.index.tolist()
y = boss.values.tolist()
data_pair = [list(z) for z in zip(x, y)]

c = (
    Pie()
    .add("", data_pair)
    .set_colors(["blue", "green", "yellow", "red", "pink", "orange", "purple"])
    .set_global_opts(title_opts=opts.TitleOpts(title="经验要求占比"))
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
)
c.render_notebook()

完整可视化代码可查看并点击网页主页(文章)左侧的流动文字免费获取哦~(可能需要往下划一下呐)

也可以直接查看文章下方推广加助理小姐姐V免费获取呐~

效果(部分)

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

尾语

好了,我的这篇文章写到这里就结束啦!

有更多建议或问题可以评论区或私信我哦!一起加油努力叭(ง •_•)ง

喜欢就关注一下博主,或点赞收藏评论一下我的文章叭!!!

请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值