岗位招聘数据分析

#导包
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
#读数据
data=pd.read_csv(r'D:\data\jobs_large.csv',sep='\t',encoding='utf8')

data.head()
#类似于数据库的describe
data.info()
#筛选列
columns = [
    'positionId', 'positionName', 'companyId',
    'companyShortName', 'companySize', 'industryField', 'financeStage',
    'skillLables', 'positionLables', 'createTime', 'city', 'salary',
    'companyLabelList', 'workYear', 'jobNature', 'education'
]

data=data[columns]
#按照positionId排序,
data.sort_values(by='positionId',inplace=True)
#查看倒数15行数据
data.tail(15)

#删除异常数据
data.drop(labels=[1421,1420,251,101,1508,1507],inplace=True)

#查看重复数据
data[data.duplicated(subset='positionId')]

#删除重复数据
data.drop_duplicates(subset='positionId',keep='first',inplace=True)
#处理salary字段
data['salary'] = data['salary'].apply(
    lambda x: int(int(x.split('-')[0][:-1]) + int(x.split('-')[1][:-1])) / 2)
#设置中文乱码问题
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False

#北上广深薪资箱线图
data[(data['city']=='北京')|(data['city']=='上海')|(data['city']=='广州')|(data['city']=='深圳')][['city','salary']].boxplot(by='city')
plt.legend()
plt.show()
#各城市平均工资
city_avg_salary=data[['city','salary']].groupby(by='city',as_index=False).agg('mean').rename(columns={'salary':'avg_salary'})
#排序
city_avg_salary.sort_values(by='avg_salary',ascending=False,inplace=True)

#图形化
city_avg_salary.plot.bar(x='city',y='avg_salary')
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页