text_plain_output_1.png image_output_1.png
import pandas as pd

import seaborn as sns

import warnings    # We want to suppress warnings

warnings.filterwarnings('ignore')
HRData = pd.read_csv('../input/WA_Fn-UseC_-HR-Employee-Attrition.csv')

HRData.isnull().any()

hrdunique = HRData.nunique()
hrdunique = hrdunique.sort_values()
hrdunique

hrd = HRData.copy()
hrd.drop('Over18', axis=1, inplace=True)
hrd.drop('StandardHours', axis=1, inplace=True)
hrd.drop('EmployeeNumber', axis=1, inplace=True)
hrd.drop('EmployeeCount', axis=1, inplace=True)

hrd.groupby('Attrition').mean()

df = pd.DataFrame(hrd, columns=['Gender', 'Department', 'Attrition'])
groupby_DeptnAttrition = df['Gender'].groupby([df['Department'], df['Attrition']])

num_bins = 30

fig,ax = plt.subplots(1, 2, figsize=(18,4)) 
sns.barplot(x = 'Attrition', y = 'DistanceFromHome', data = hrd, ax = ax[0])
sns.barplot(x = 'Gender',y = 'JobSatisfaction', data = hrd, ax = ax[1])

fig = plt.figure(figsize=(12, 12))
sns.distplot(hrd.JobSatisfaction, hist=False, kde=True, label='Job Satisfaction', hist_kws={'histtype': 'step', 'linewidth': 3, 'alpha': 1, 'color': sns.xkcd_rgb['blue']})
sns.distplot(hrd.EnvironmentSatisfaction, hist=False, kde=True, label='Environment Satisfaction', hist_kws={'histtype': 'step', 'linewidth': 3, 'alpha': 1, 'color': sns.xkcd_rgb['red']})
sns.distplot(hrd.RelationshipSatisfaction, hist=False, kde=True, label='Relationship Satisfaction', hist_kws={'histtype': 'step', 'linewidth': 3, 'alpha': 1, 'color': sns.xkcd_rgb['green']})
plt.suptitle('Satisfaction Levels of Employees', size=22, x=0.5, y=0.94)
plt.xlabel('Satisfaction Levels', size=10)
plt.legend()