<jupyter_start><jupyter_text>Case - PeopleThis notebook covers the data analysis case using Sample employee dataset that you can donload from Moodle. Keep in mind, that to read the data either put it in the same folder with your Jupyter Notebook or provide the full path (address) of hte file like I have done.Almost no new function is provided in this notebook, but the combination of materials convered before is used to:- analyse values in different columns (by printing unique values if they are not many or by plotting hteir distribution),- convert objects into numeric using np.where or astype("category").cat.reorder_cateogires([]),cat.codes approach or pd.get_dummies(),- calculate average satisfaction per salary group using pivot tables,- calculat epercentage of employees who left the company (churn==1).<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
#important to know: reading files from different folders
data = pd.read_csv(r"C:\Users\ADstudent\Downloads\People.csv")
data.head(3)
data.info()
data_num = data.select_dtypes(exclude=["object"])
data_obj = data.select_dtypes(include=["object"])
data_num.describe()
#print unique values for the first 2 columns
for i in range(0,2):
    print(data_obj.iloc[:,i].unique())
data.head()
#for all columns, if unqieu values are less than 11, print them
for i in data.columns:
    unique_values = data[i].unique()
    num_unique = len(unique_values)
    if num_unique<11:
        print(i,unique_values)
#not for exam, critically important for Business Analytics
data.salary = data.salary.astype("category").cat.reorder_categories(['low', 'medium', 'high']).cat.codes
data.head(3)
data.department.astype("category").cat.reorder_categories(['sales', 'accounting', 'hr', 'technical', 'support' ,'management', 'IT',
 'product_mng', 'marketing', 'RandD']).cat.codes
#not for exam, critically important for Business Analytics
departments = pd.get_dummies(data.department,prefix="department")
data = data.join(departments)
data.head(3)
#important: axis=1 indicates that we are dropping a column, not a row
data = data.drop("department",axis=1)
data.info()
#plot the distribution of values for hte first 2 columns
for i in range(0,2):
    sns.distplot(data.iloc[:,i])
    plt.show()
#select several columns by providing them asa list
data.iloc[:,[1,2,5]]
sat_level = pd.pivot_table(data,index="salary",values="satisfaction_level",aggfunc="mean")
sat_level
data.churn.value_counts()/len(data)*100
#important but could also learn with data.info()
data.shape
#plot the distribution without using seaborn
data.plot(y="satisfaction_level",kind="density")
#plot the distribution without using seaborn
data.plot(y="satisfaction_level",kind="hist")
#plot the distribution using seaborn
sns.distplot(data.satisfaction_level)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11013679410733077, 'fraction_numerical': 0.007716590669940372, 'mean_word_length': 6.112219451371571, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '642751', 'license': 'Apache-2.0', 'n_tokens_mistral': 881, 'n_tokens_neox': 848, 'n_words': 293, 'path': 'Case-People.ipynb', 'repo_name': 'HrantDavtyan/MSSM_Business_Analytics', 'size': '2851'}