科学导论 数据预处理

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as matplot
import seaborn as sns
%matplotlib inlineprice_discretized2
df = pd.DataFrame.from_csv('ch3-Turnover.csv',index_col=None)
df.isnull().any()
df.head()
df = df.rename(columns={'satisfaction_level':'satisfaction','last_evaluation':'evaluation','number_porject':'projectCount'
                        ,'average_montly_hours':'averageMonthlyHours','time_spend_company':'yearsAtCompany',"work_accident":'workAccident'
                        ,'promotion_last_5years':'promotion','sales':'deparment','left':'turnover'})
front =df["turnover"]
df.drop(labels=['turnover'],axis=1,inplace =True)
df.insert(0,'turnover',front)
df.head()

df.shape
df.dtypes
turnover_rate =df.turnover.value_counts()/len(df)
turnover_rate(14999,10)
df.describe()
turnover_Summary = df.groupby("turnover")
turnover_Summary.mean()
corr = df.corr()
corr =(corr)
sns.heatmap(corr,xticklabels=corr.columns.value,yticklabels=corr.columns.value)

#设置matplotlib figure 格式
f,axes =plt.subplots(ncols=3,figszie=(15,6))
#Employee Satisfaction 图像
sns.displot(df.satisfaction,kde=False,color='g',ax=axes[0]).set_title('Employee Satisfaction Distribution')
axes[0].set_ylabel('Employee Count')
#Employee Evaluation
sns.displot(df.satisfaction,kde=False,color='g',ax=axes[1]).set_title('Employee Evaluation Distribution')
axes[1].set_ylabel('Employee Count')
#Employ Average Monthly Hours 图像
sns.displot(df.satisfaction,kde=False,color='g',ax=axes[2]).set_title('Employee Average Monthly Hours Distribution')
axes[2].set_ylabel('Employee Count')
f,axes =plt.subplots(ncols=3,figszie=(15,4))
sns.countplot(y="salary",hue='turnover',data=df).set_title('Employ Salary Turnover Distribution');
  • 23
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值