<jupyter_start><jupyter_text>Job SatisfactionIn this notebook, you will be exploring job satisfaction according to the survey results.  Use the cells at the top of the notebook to explore as necessary, and use your findings to solve the questions at the bottom of the notebook.<jupyter_code>import pandas as pd
import numpy as np
import JobSatisfaction as t
import matplotlib.pyplot as plt
%matplotlib inline

df = pd.read_csv('./survey_results_public.csv')
schema = pd.read_csv('./survey_results_schema.csv')
df.head()
# missing values
df.JobSatisfaction.isnull().mean()
df.JobSatisfaction[df.EmploymentStatus == 'Employed full-time'].mean()
job_sat = pd.DataFrame(data = {'EmploymentStatus': [], 'JobSatisfaction':[]})
def job_sat_feature(df,feature_col,print_bool = False):
    """ Given the data frame and a specific column, returns a new data
        frame containing the average job satisfaction for each unique value of that column
    """
    value_list = []
    sat_list = []
    for value in df[feature_col].unique():
        value_list.append(value)
        satisfaction = df.JobSatisfaction[df[feature_col] == value].mean() - df.JobSatisfaction.mean()
        sat_list.append(satisfaction)
    df_jobsat = pd.DataFrame(data = {feature_col: value_list, 'JobSatisfaction':sat_list}).sort_values(by='JobSatisfaction')
    
    if print_bool == True:
        df_jobsat.plot(kind='bar',x = feature_col, y = 'JobSatisfaction', legend= False, title='Job Satisfaction')
        plt.show()
    return df_jobsat


job_sat = job_sat_feature(df,'EmploymentStatus',True)

display(job_sat)
# Job Satisfaction
stat_list = []
sat_list = []
for status in df.EmploymentStatus.unique():
    stat_list.append(status)
    satisfaction = df.JobSatisfaction[df.EmploymentStatus == status].mean()
    sat_list.append(satisfaction)
    print('Status: {0} \nSatisfaction: {1}\n-------------'.format(status, satisfaction))
    
job_sat = pd.DataFrame(data = {'EmploymentStatus': stat_list, 'JobSatisfaction':sat_list})
display(job_sat)
# CompanySize
company_sat = job_sat_feature(df,'CompanySize',True)

# Hobby
company_sat = job_sat_feature(df,'ProgramHobby',True)

# HomeRemote
company_sat = job_sat_feature(df,'HomeRemote',True)

# PhD
company_sat = job_sat_feature(df,'FormalEducation',True)<jupyter_output><empty_output><jupyter_text>Question 1**1.** Use the space above to assist in matching each variable (**a**, **b**, **c**, **d**, **e**, **f**, **g**, or **h** ) as the appropriate key that describes the value in the **job_sol_1** dictionary.<jupyter_code>a = 0.734
b = 0.2014
c = 'full-time'
d = 'contractors'
e = 'retired'
f = 'yes'
g = 'no'
h = 'hard to tell'

job_sol_1 = {'The proportion of missing values in the Job Satisfaction column': b,
             'According to EmploymentStatus, which group has the highest average job satisfaction?': d, 
             'In general, do smaller companies appear to have employees with higher job satisfaction?': f}
             
t.jobsat_check1(job_sol_1)<jupyter_output>Nice job! That's what we found as well!<jupyter_text>Question 2**2.** Use the space above to assist in matching each variable (**a**, **b**, **c** ) as the appropriate key that describes the value in the **job_sol_2** dictionary. Notice you can have the same letter appear more than once.<jupyter_code>a = 'yes'
b = 'no'
c = 'hard to tell'

job_sol_2 = {'Do individuals who program outside of work appear to have higher JobSatisfaction?': a,
             'Does flexibility to work outside of the office appear to have an influence on JobSatisfaction?': a, 
             'A friend says a Doctoral degree increases the chance of having job you like, does this seem true?': a}
             
t.jobsat_check2(job_sol_2)
df.groupby('CompanySize').mean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12011615628299895, 'fraction_numerical': 0.006071805702217529, 'mean_word_length': 4.547584187408492, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '289494', 'license': 'MIT', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1150, 'n_words': 362, 'path': 'lessons/CRISP_DM/Job Satisfaction.ipynb', 'repo_name': 'larpal/DSND_Term2', 'size': '3788'}