导入查看数据
df=pd.read_csv('lagou1.csv')
df.head(3)
查看数据
df.shape
df.info()
缺失值处理
提取出公司名称缺失的行,并删除该行
df[df['公司名称'].isnull()]
df.dropna(subset=['公司名称'],axis=0,inplace=True)
提取出公司地点有缺失的行, 并且删除这些行
df[df['公司地点'].isnull()]
df.dropna(subset=['公司地点'],axis=0,inplace=True)
提取出城市中有缺失的行
# 检查
df[df['城市'].isnull()]
# 方法一
df['城市'].loc[[871,874]]='南京'
df['城市'].loc[[1617,1618,1619]]='武汉'
# 检查
df['城市'].loc[[871,874]]
df['城市'].loc[[1617,1618,1619]]
# 方法二
df.loc[[871,874],'城市']='南京'
df.loc[[1617,1618,1619],'城市']='武汉'
## 提取出岗位技能缺失的行,并填充
df[df['岗位技能'].isnull()]
df['岗位技能']=df['岗位技能'].fillna('无要求')
去除重复值
# 查看重复的行
df[df.duplicated()]
# 对重复行计数
df.duplicated().sum()
df.drop_duplicates(inplace=True)
公司地点,公司短评处理
df['公司地点']=df['公司地点'].str.strip('[]')
df['公司短评']=df['公司短评'].str.strip('“”')
对公司级别进行切分
df['行业']=df['公司级别'].str.split('/').str.get(0).str.strip(' ')
df['行业'].unique()
df['融资']=df['公司级别'].str.split('/').str.get(1).str.strip(' ')
df['融资'].unique()
df['规模']=df['公司级别'].str.split('/').str.get(2).str.strip(' ')
df['规模'].unique()
对工位要求进行切分
df['薪资']=df['工位要求'].str.split(' ').str.get(0).str.strip(' ')
df['薪资'].unique()
df[df['薪资'].str.contains('经验')]
df.loc[[868,875,1624],'经验']=df.loc[[865,871,1541],'薪资']
df.loc[[868,875,1624]]
df.loc[[868,875,1624],'薪资']=['10k-15k','10k-15k','20k-25k']
df['经验']=df['工位要求'].str.split(' ').str.get(1).str.strip(' ')
df['经验'].unique()
array(['经验3-5年', '经验不限', '经验1-3年', '经验5-10年', '经验1年以下', '经验应届毕业生',
'经验10年以上', '/'], dtype=object)
df[df['经验'].str.contains('/')]
df.loc[[868,875,1624],'经验']=df.loc[[865,871,1541],'薪资']
df[(df['城市']=='南京')&(df['经验']=='经验1-3年')]
df['学历']=df['工位要求'].str.split(' ').str.get(-1).str.strip(' ')
df['学历'].unique()
array(['本科', '大专', '不限', '硕士', '博士', '经验3-5年'], dtype=object)
df.drop('工位要求',axis=1,inplace=True)
把标题修改为岗位名称
df.head(3)
df.rename({'标题':'岗位名称'},axis=1,inplace=True)
保存
df.to_csv('lagouo-clean.csv')








暂无数据