text_plain_output_1.png image_output_1.png
import numpy as np

import pandas as pd

import seaborn as sns

data = pd.read_csv('../input/HR_comma_sep.csv')

corr = data.corr()
corr = corr
corr

data.loc[data['avg_hour_project'] <= 749.333, 'avg_hour_project'] = 0
data.loc[(data['avg_hour_project'] > 749.333) & (data['avg_hour_project'] <= 1304.667), 'avg_hour_project'] = 1
data.loc[(data['avg_hour_project'] > 1304.667) & (data['avg_hour_project'] <= 1860.0), 'avg_hour_project'] = 2
data.drop(['avg_hour_project_range'], axis=1, inplace=True)

g = sns.FacetGrid(data, col='left')
g.map(sns.boxplot, 'time_spend_company')

dropdata = data[data['time_spend_company'] >= 8]
data.drop(dropdata.index, inplace=True)

g = sns.FacetGrid(data, hue='left', aspect=4)
g.map(sns.kdeplot, 'average_montly_hours', shade=True)
g.set(xlim=(0, data['average_montly_hours'].max()))
g.add_legend()

g = sns.FacetGrid(data, col='left')
g.map(sns.boxplot, 'average_montly_hours')
(np.mean(data[data['left'] == 1]['average_montly_hours']), np.mean(data[data['left'] == 0]['average_montly_hours']))

data.loc[data['average_montly_hours'] <= 167.333, 'average_montly_hours'] = 0
data.loc[(data['average_montly_hours'] > 167.333) & (data['average_montly_hours'] <= 238.667), 'average_montly_hours'] = 1
data.loc[(data['average_montly_hours'] > 238.667) & (data['average_montly_hours'] <= 310.0), 'average_montly_hours'] = 2
data.drop(['avg_mon_hours_range'], axis=1, inplace=True)

sns.barplot(x='number_project', y='left', data=data)
sns.plt.title('Left over Number of project')