# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # HR ANALYSIS: 

# ## In this module, we describe how to analyze a HR Spreadsheet for those who are applying for post of Data Analyst and Data Scientist in a Company

# Importing the required libraries
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
# %matplotlib inline

#Importing csv file containing form entries
hr_data= pd.read_csv('Spreadsheet.csv')

#Displaying the Top 5 rows in Data Set
hr_data.head()

# # DATA PREPROCESSING:

#Check if any Column's has NA or Missing Values
hr_data.isnull().any()

#Shape of the Data
hr_data.shape

#Data Types of Columns
hr_data.dtypes

hr_data.columns = ['Timestamp','Name','Gender','Age','Experience','Job_Role','Python_Skill','R_Skill','SQL_Skill','Advanced_Excel_Skill','Data_Visualization_Skill','Machine_Learning_Skill','SAS_Skill','Apache_Spark_Skill','AWS_Skill','Deep_Learning_Skill']

hr_data.set_index('Timestamp',inplace=True)

hr_data

# # EXPLORATORY DATA ANALYSIS:

#Percentage Distribution
hr_data.Job_Role.value_counts(normalize=True)

plt.figure(figsize=(8,6))
Job=hr_data.Job_Role.value_counts()
sns.barplot(x=Job.index ,y=Job.values)
plt.title('Distribution of Employee ')
plt.xlabel('Employee Type', fontsize=16)
plt.ylabel('Count', fontsize=16)

hr_data.groupby(["Job_Role","Gender"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR GENDER")
plt.xlabel("JOB ROLE")

df1=hr_data[hr_data["Job_Role"]=='Data Scientist']

df2=hr_data[hr_data["Job_Role"]=='Data Analyst']

sns.set(rc={'figure.figsize':(12,8)})
sns.distplot(df1['Age'])
plt.title("DENSITY GRAPH FOR AGE WISE DISTRIBUTION OF DATA SCIENTIST")
plt.ylabel("DENSITY")
plt.xlabel("AGE")
df1['Age'].mean()

sns.set(rc={'figure.figsize':(12,8)})
sns.distplot(df2['Age'])
plt.title("DENSITY GRAPH FOR AGE WISE DISTRIBUTION OF DATA ANALYST")
plt.ylabel("DENSITY")
plt.xlabel("AGE")
df2['Age'].mean()

sns.set(rc={'figure.figsize':(12,8)})
sns.distplot(df1['Experience'])
plt.title("DENSITY GRAPH FOR EXPERIENCE WISE DISTRIBUTION OF DATA SCIENTIST")
plt.ylabel("DENSITY")
plt.xlabel("EXPERIENCE")
df1['Experience'].mean()


# +
sns.set(rc={'figure.figsize':(12,8)})
sns.distplot(df2['Experience'])
plt.title("DENSITY GRAPH FOR EXPERIENCE WISE DISTRIBUTION OF DATA ANALYST")
plt.ylabel("DENSITY")
plt.xlabel("EXPERIENCE")
df2['Experience'].mean()



# -

#Code for construction of Box Plot
hr_data.boxplot(by='Job_Role',column=['Age'],grid=False,figsize=(8,8))
plt.title("BOX PLOT GROUPED BY AGE")
plt.xlabel("JOB ROLE")
plt.ylabel("AGE")

#Code for construction of Box Chart Sale Made by the Customer based on their Months since last buy
#Code for construction of Box Plot
hr_data.boxplot(by='Job_Role',column=['Experience'],grid=False,figsize=(8,8))
plt.title("BOX PLOT GROUPED BY EXPERIENCE")
plt.xlabel("JOB ROLE")
plt.ylabel("EXPERIENCE")

hr_data.groupby(["Job_Role","Python_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR PYTHON SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","R_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR R SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","SQL_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR SQL SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","Advanced_Excel_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR ADVANCED EXCEL SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","Data_Visualization_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR DATA VISAUALIZATION SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","Machine_Learning_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR ML SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","SAS_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR SAS SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","Apache_Spark_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR APACHE SPARK SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","AWS_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR AWS SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

hr_data.groupby(["Job_Role","Deep_Learning_Skill"]).size().unstack().plot(kind = "bar", stacked = True,figsize=(8,8))
plt.title("STACKED BAR CHART FOR DEEP LEARNING SKILL")
plt.ylabel("SKILL LEVEL")
plt.xlabel("JOB ROLE")

StarcoderdataJupyterScriptsDedupFiltered