project aim : answer following question for Stackeholders
we have two dataset: 1- dete_survey: have follwing columns
ID: An id used to identify the participant of the survey
SeparationType: The reason why the person's employment ended
Cease Date: The year or month the person's employment ended
DETE Start Date: The year the person began employment with the DETE.
2- tafe_survey: have follwing columns
Record ID: An id used to identify the participant of the survey
Reason for ceasing employment: The reason why the person's employment ended
LengthofServiceOverall. Overall Length of Service at Institute (in years): The length of the person's employment (in years)
solutions:[https://github.com/dataquestio/solutions/blob/master/Mission348Solutions.ipynb]
# Import Basic library
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
create read_file() function to read dataset:
1- which take only one parameter file_name
2- return dataframe
# read_file() function
def read_file(file_name):
df=pd.read_csv(file_name)
return df
# read dete_survey.csv file & assign it to data_survey variable
dete_survey=read_file("dete_survey.csv")
# read tafe_survey.csv file & assign it to tafe_survey variable
tafe_survey=read_file("tafe_survey.csv")
create explore_df() function to explore most important information in dataset, which take 2 parameter :
1-dataframe
2-dataset name as string
# create explore_df()
def explore_df(df,df_name):
# print important df info using pd.info()
print(df_name)
print(df.info(),"\n")
# print top 5 using pd.head()
print("top 5\n",df.head(),"\n")
# print first row
print("first rows\n",df.iloc[0],"\n")
# explore some statistics using pd.describe()
print("descibe data\n",df.describe())
# explore columns have null values
print("null values\n",df.isnull().sum())
# explore dete_survey
explore_df(dete_survey,"dete_survey")
dete_survey <class 'pandas.core.frame.DataFrame'> RangeIndex: 822 entries, 0 to 821 Data columns (total 56 columns): ID 822 non-null int64 SeparationType 822 non-null object Cease Date 822 non-null object DETE Start Date 822 non-null object Role Start Date 822 non-null object Position 817 non-null object Classification 455 non-null object Region 822 non-null object Business Unit 126 non-null object Employment Status 817 non-null object Career move to public sector 822 non-null bool Career move to private sector 822 non-null bool Interpersonal conflicts 822 non-null bool Job dissatisfaction 822 non-null bool Dissatisfaction with the department 822 non-null bool Physical work environment 822 non-null bool Lack of recognition 822 non-null bool Lack of job security 822 non-null bool Work location 822 non-null bool Employment conditions 822 non-null bool Maternity/family 822 non-null bool Relocation 822 non-null bool Study/Travel 822 non-null bool Ill Health 822 non-null bool Traumatic incident 822 non-null bool Work life balance 822 non-null bool Workload 822 non-null bool None of the above 822 non-null bool Professional Development 808 non-null object Opportunities for promotion 735 non-null object Staff morale 816 non-null object Workplace issue 788 non-null object Physical environment 817 non-null object Worklife balance 815 non-null object Stress and pressure support 810 non-null object Performance of supervisor 813 non-null object Peer support 812 non-null object Initiative 813 non-null object Skills 811 non-null object Coach 767 non-null object Career Aspirations 746 non-null object Feedback 792 non-null object Further PD 768 non-null object Communication 814 non-null object My say 812 non-null object Information 816 non-null object Kept informed 813 non-null object Wellness programs 766 non-null object Health & Safety 793 non-null object Gender 798 non-null object Age 811 non-null object Aboriginal 16 non-null object Torres Strait 3 non-null object South Sea 7 non-null object Disability 23 non-null object NESB 32 non-null object dtypes: bool(18), int64(1), object(37) memory usage: 258.6+ KB None top 5 ID SeparationType Cease Date DETE Start Date \ 0 1 Ill Health Retirement 08/2012 1984 1 2 Voluntary Early Retirement (VER) 08/2012 Not Stated 2 3 Voluntary Early Retirement (VER) 05/2012 2011 3 4 Resignation-Other reasons 05/2012 2005 4 5 Age Retirement 05/2012 1970 Role Start Date Position \ 0 2004 Public Servant 1 Not Stated Public Servant 2 2011 Schools Officer 3 2006 Teacher 4 1989 Head of Curriculum/Head of Special Education Classification Region Business Unit \ 0 A01-A04 Central Office Corporate Strategy and Peformance 1 AO5-AO7 Central Office Corporate Strategy and Peformance 2 NaN Central Office Education Queensland 3 Primary Central Queensland NaN 4 NaN South East NaN Employment Status ... Kept informed Wellness programs \ 0 Permanent Full-time ... N N 1 Permanent Full-time ... N N 2 Permanent Full-time ... N N 3 Permanent Full-time ... A N 4 Permanent Full-time ... N A Health & Safety Gender Age Aboriginal Torres Strait South Sea \ 0 N Male 56-60 NaN NaN NaN 1 N Male 56-60 NaN NaN NaN 2 N Male 61 or older NaN NaN NaN 3 A Female 36-40 NaN NaN NaN 4 M Female 61 or older NaN NaN NaN Disability NESB 0 NaN Yes 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 NaN NaN [5 rows x 56 columns] first rows ID 1 SeparationType Ill Health Retirement Cease Date 08/2012 DETE Start Date 1984 Role Start Date 2004 Position Public Servant Classification A01-A04 Region Central Office Business Unit Corporate Strategy and Peformance Employment Status Permanent Full-time Career move to public sector True Career move to private sector False Interpersonal conflicts False Job dissatisfaction True Dissatisfaction with the department False Physical work environment False Lack of recognition True Lack of job security False Work location False Employment conditions False Maternity/family False Relocation False Study/Travel False Ill Health False Traumatic incident False Work life balance False Workload False None of the above True Professional Development A Opportunities for promotion A Staff morale N Workplace issue N Physical environment N Worklife balance A Stress and pressure support A Performance of supervisor A Peer support A Initiative N Skills N Coach N Career Aspirations A Feedback A Further PD A Communication N My say A Information A Kept informed N Wellness programs N Health & Safety N Gender Male Age 56-60 Aboriginal NaN Torres Strait NaN South Sea NaN Disability NaN NESB Yes Name: 0, dtype: object descibe data ID count 822.000000 mean 411.693431 std 237.705820 min 1.000000 25% 206.250000 50% 411.500000 75% 616.750000 max 823.000000 null values ID 0 SeparationType 0 Cease Date 0 DETE Start Date 0 Role Start Date 0 Position 5 Classification 367 Region 0 Business Unit 696 Employment Status 5 Career move to public sector 0 Career move to private sector 0 Interpersonal conflicts 0 Job dissatisfaction 0 Dissatisfaction with the department 0 Physical work environment 0 Lack of recognition 0 Lack of job security 0 Work location 0 Employment conditions 0 Maternity/family 0 Relocation 0 Study/Travel 0 Ill Health 0 Traumatic incident 0 Work life balance 0 Workload 0 None of the above 0 Professional Development 14 Opportunities for promotion 87 Staff morale 6 Workplace issue 34 Physical environment 5 Worklife balance 7 Stress and pressure support 12 Performance of supervisor 9 Peer support 10 Initiative 9 Skills 11 Coach 55 Career Aspirations 76 Feedback 30 Further PD 54 Communication 8 My say 10 Information 6 Kept informed 9 Wellness programs 56 Health & Safety 29 Gender 24 Age 11 Aboriginal 806 Torres Strait 819 South Sea 815 Disability 799 NESB 790 dtype: int64
# explore tafe_survey
explore_df(tafe_survey,"tafe_survey")
tafe_survey <class 'pandas.core.frame.DataFrame'> RangeIndex: 702 entries, 0 to 701 Data columns (total 72 columns): Record ID 702 non-null float64 Institute 702 non-null object WorkArea 702 non-null object CESSATION YEAR 695 non-null float64 Reason for ceasing employment 701 non-null object Contributing Factors. Career Move - Public Sector 437 non-null object Contributing Factors. Career Move - Private Sector 437 non-null object Contributing Factors. Career Move - Self-employment 437 non-null object Contributing Factors. Ill Health 437 non-null object Contributing Factors. Maternity/Family 437 non-null object Contributing Factors. Dissatisfaction 437 non-null object Contributing Factors. Job Dissatisfaction 437 non-null object Contributing Factors. Interpersonal Conflict 437 non-null object Contributing Factors. Study 437 non-null object Contributing Factors. Travel 437 non-null object Contributing Factors. Other 437 non-null object Contributing Factors. NONE 437 non-null object Main Factor. Which of these was the main factor for leaving? 113 non-null object InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction 608 non-null object InstituteViews. Topic:2. I was given access to skills training to help me do my job better 613 non-null object InstituteViews. Topic:3. I was given adequate opportunities for personal development 610 non-null object InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL% 608 non-null object InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had 615 non-null object InstituteViews. Topic:6. The organisation recognised when staff did good work 607 non-null object InstituteViews. Topic:7. Management was generally supportive of me 614 non-null object InstituteViews. Topic:8. Management was generally supportive of my team 608 non-null object InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me 610 non-null object InstituteViews. Topic:10. Staff morale was positive within the Institute 602 non-null object InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly 601 non-null object InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently 597 non-null object InstituteViews. Topic:13. If I had a workplace issue it was dealt with discreetly 601 non-null object WorkUnitViews. Topic:14. I was satisfied with the quality of the management and supervision within my work unit 609 non-null object WorkUnitViews. Topic:15. I worked well with my colleagues 605 non-null object WorkUnitViews. Topic:16. My job was challenging and interesting 607 non-null object WorkUnitViews. Topic:17. I was encouraged to use my initiative in the course of my work 610 non-null object WorkUnitViews. Topic:18. I had sufficient contact with other people in my job 613 non-null object WorkUnitViews. Topic:19. I was given adequate support and co-operation by my peers to enable me to do my job 609 non-null object WorkUnitViews. Topic:20. I was able to use the full range of my skills in my job 609 non-null object WorkUnitViews. Topic:21. I was able to use the full range of my abilities in my job. ; Category:Level of Agreement; Question:YOUR VIEWS ABOUT YOUR WORK UNIT] 608 non-null object WorkUnitViews. Topic:22. I was able to use the full range of my knowledge in my job 608 non-null object WorkUnitViews. Topic:23. My job provided sufficient variety 611 non-null object WorkUnitViews. Topic:24. I was able to cope with the level of stress and pressure in my job 610 non-null object WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction 611 non-null object WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance 606 non-null object WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area 610 non-null object WorkUnitViews. Topic:28. I was given the opportunity to mentor and coach others in order for me to pass on my skills and knowledge prior to my cessation date 609 non-null object WorkUnitViews. Topic:29. There was adequate communication between staff in my unit 603 non-null object WorkUnitViews. Topic:30. Staff morale was positive within my work unit 606 non-null object Induction. Did you undertake Workplace Induction? 619 non-null object InductionInfo. Topic:Did you undertake a Corporate Induction? 432 non-null object InductionInfo. Topic:Did you undertake a Institute Induction? 483 non-null object InductionInfo. Topic: Did you undertake Team Induction? 440 non-null object InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted? 555 non-null object InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted? 555 non-null object InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction? 555 non-null object InductionInfo. Face to Face Topic:Did you undertake a Institute Induction? 530 non-null object InductionInfo. On-line Topic:Did you undertake a Institute Induction? 555 non-null object InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction? 553 non-null object InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category? 555 non-null object InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.] 555 non-null object InductionInfo. Induction Manual Topic: Did you undertake Team Induction? 555 non-null object Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)? 608 non-null object Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination? 594 non-null object Workplace. Topic:Does your workplace promote and practice the principles of employment equity? 587 non-null object Workplace. Topic:Does your workplace value the diversity of its employees? 586 non-null object Workplace. Topic:Would you recommend the Institute as an employer to others? 581 non-null object Gender. What is your Gender? 596 non-null object CurrentAge. Current Age 596 non-null object Employment Type. Employment Type 596 non-null object Classification. Classification 596 non-null object LengthofServiceOverall. Overall Length of Service at Institute (in years) 596 non-null object LengthofServiceCurrent. Length of Service at current workplace (in years) 596 non-null object dtypes: float64(2), object(70) memory usage: 395.0+ KB None top 5 Record ID Institute \ 0 6.341330e+17 Southern Queensland Institute of TAFE 1 6.341337e+17 Mount Isa Institute of TAFE 2 6.341388e+17 Mount Isa Institute of TAFE 3 6.341399e+17 Mount Isa Institute of TAFE 4 6.341466e+17 Southern Queensland Institute of TAFE WorkArea CESSATION YEAR Reason for ceasing employment \ 0 Non-Delivery (corporate) 2010.0 Contract Expired 1 Non-Delivery (corporate) 2010.0 Retirement 2 Delivery (teaching) 2010.0 Retirement 3 Non-Delivery (corporate) 2010.0 Resignation 4 Delivery (teaching) 2010.0 Resignation Contributing Factors. Career Move - Public Sector \ 0 NaN 1 - 2 - 3 - 4 - Contributing Factors. Career Move - Private Sector \ 0 NaN 1 - 2 - 3 - 4 Career Move - Private Sector Contributing Factors. Career Move - Self-employment \ 0 NaN 1 - 2 - 3 - 4 - Contributing Factors. Ill Health Contributing Factors. Maternity/Family \ 0 NaN NaN 1 - - 2 - - 3 - - 4 - - ... \ 0 ... 1 ... 2 ... 3 ... 4 ... Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination? \ 0 Yes 1 Yes 2 Yes 3 Yes 4 Yes Workplace. Topic:Does your workplace promote and practice the principles of employment equity? \ 0 Yes 1 Yes 2 Yes 3 Yes 4 Yes Workplace. Topic:Does your workplace value the diversity of its employees? \ 0 Yes 1 Yes 2 Yes 3 Yes 4 Yes Workplace. Topic:Would you recommend the Institute as an employer to others? \ 0 Yes 1 Yes 2 Yes 3 Yes 4 Yes Gender. What is your Gender? CurrentAge. Current Age \ 0 Female 26 30 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 Male 41 45 Employment Type. Employment Type Classification. Classification \ 0 Temporary Full-time Administration (AO) 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 Permanent Full-time Teacher (including LVT) LengthofServiceOverall. Overall Length of Service at Institute (in years) \ 0 1-2 1 NaN 2 NaN 3 NaN 4 3-4 LengthofServiceCurrent. Length of Service at current workplace (in years) 0 1-2 1 NaN 2 NaN 3 NaN 4 3-4 [5 rows x 72 columns] first rows Record ID 6.34133e+17 Institute Southern Queensland Institute of TAFE WorkArea Non-Delivery (corporate) CESSATION YEAR 2010 Reason for ceasing employment Contract Expired Contributing Factors. Career Move - Public Sector NaN Contributing Factors. Career Move - Private Sector NaN Contributing Factors. Career Move - Self-employment NaN Contributing Factors. Ill Health NaN Contributing Factors. Maternity/Family NaN Contributing Factors. Dissatisfaction NaN Contributing Factors. Job Dissatisfaction NaN Contributing Factors. Interpersonal Conflict NaN Contributing Factors. Study NaN Contributing Factors. Travel NaN Contributing Factors. Other NaN Contributing Factors. NONE NaN Main Factor. Which of these was the main factor for leaving? NaN InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction Agree InstituteViews. Topic:2. I was given access to skills training to help me do my job better Agree InstituteViews. Topic:3. I was given adequate opportunities for personal development Agree InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL% Neutral InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had Agree InstituteViews. Topic:6. The organisation recognised when staff did good work Agree InstituteViews. Topic:7. Management was generally supportive of me Agree InstituteViews. Topic:8. Management was generally supportive of my team Agree InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me Agree InstituteViews. Topic:10. Staff morale was positive within the Institute Agree InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly Agree InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently Agree ... WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction Agree WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance Agree WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area Agree WorkUnitViews. Topic:28. I was given the opportunity to mentor and coach others in order for me to pass on my skills and knowledge prior to my cessation date Neutral WorkUnitViews. Topic:29. There was adequate communication between staff in my unit Agree WorkUnitViews. Topic:30. Staff morale was positive within my work unit Agree Induction. Did you undertake Workplace Induction? Yes InductionInfo. Topic:Did you undertake a Corporate Induction? Yes InductionInfo. Topic:Did you undertake a Institute Induction? Yes InductionInfo. Topic: Did you undertake Team Induction? Yes InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted? Face to Face InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted? - InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction? - InductionInfo. Face to Face Topic:Did you undertake a Institute Induction? Face to Face InductionInfo. On-line Topic:Did you undertake a Institute Induction? - InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction? - InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category? Face to Face InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.] - InductionInfo. Induction Manual Topic: Did you undertake Team Induction? - Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)? Yes Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination? Yes Workplace. Topic:Does your workplace promote and practice the principles of employment equity? Yes Workplace. Topic:Does your workplace value the diversity of its employees? Yes Workplace. Topic:Would you recommend the Institute as an employer to others? Yes Gender. What is your Gender? Female CurrentAge. Current Age 26 30 Employment Type. Employment Type Temporary Full-time Classification. Classification Administration (AO) LengthofServiceOverall. Overall Length of Service at Institute (in years) 1-2 LengthofServiceCurrent. Length of Service at current workplace (in years) 1-2 Name: 0, Length: 72, dtype: object descibe data Record ID CESSATION YEAR count 7.020000e+02 695.000000 mean 6.346026e+17 2011.423022 std 2.515071e+14 0.905977 min 6.341330e+17 2009.000000 25% 6.343954e+17 2011.000000 50% 6.345835e+17 2011.000000 75% 6.348005e+17 2012.000000 max 6.350730e+17 2013.000000 null values Record ID 0 Institute 0 WorkArea 0 CESSATION YEAR 7 Reason for ceasing employment 1 Contributing Factors. Career Move - Public Sector 265 Contributing Factors. Career Move - Private Sector 265 Contributing Factors. Career Move - Self-employment 265 Contributing Factors. Ill Health 265 Contributing Factors. Maternity/Family 265 Contributing Factors. Dissatisfaction 265 Contributing Factors. Job Dissatisfaction 265 Contributing Factors. Interpersonal Conflict 265 Contributing Factors. Study 265 Contributing Factors. Travel 265 Contributing Factors. Other 265 Contributing Factors. NONE 265 Main Factor. Which of these was the main factor for leaving? 589 InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction 94 InstituteViews. Topic:2. I was given access to skills training to help me do my job better 89 InstituteViews. Topic:3. I was given adequate opportunities for personal development 92 InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL% 94 InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had 87 InstituteViews. Topic:6. The organisation recognised when staff did good work 95 InstituteViews. Topic:7. Management was generally supportive of me 88 InstituteViews. Topic:8. Management was generally supportive of my team 94 InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me 92 InstituteViews. Topic:10. Staff morale was positive within the Institute 100 InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly 101 InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently 105 ... WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction 91 WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance 96 WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area 92 WorkUnitViews. Topic:28. I was given the opportunity to mentor and coach others in order for me to pass on my skills and knowledge prior to my cessation date 93 WorkUnitViews. Topic:29. There was adequate communication between staff in my unit 99 WorkUnitViews. Topic:30. Staff morale was positive within my work unit 96 Induction. Did you undertake Workplace Induction? 83 InductionInfo. Topic:Did you undertake a Corporate Induction? 270 InductionInfo. Topic:Did you undertake a Institute Induction? 219 InductionInfo. Topic: Did you undertake Team Induction? 262 InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted? 147 InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted? 147 InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction? 147 InductionInfo. Face to Face Topic:Did you undertake a Institute Induction? 172 InductionInfo. On-line Topic:Did you undertake a Institute Induction? 147 InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction? 149 InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category? 147 InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.] 147 InductionInfo. Induction Manual Topic: Did you undertake Team Induction? 147 Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)? 94 Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination? 108 Workplace. Topic:Does your workplace promote and practice the principles of employment equity? 115 Workplace. Topic:Does your workplace value the diversity of its employees? 116 Workplace. Topic:Would you recommend the Institute as an employer to others? 121 Gender. What is your Gender? 106 CurrentAge. Current Age 106 Employment Type. Employment Type 106 Classification. Classification 106 LengthofServiceOverall. Overall Length of Service at Institute (in years) 106 LengthofServiceCurrent. Length of Service at current workplace (in years) 106 Length: 72, dtype: int64
for both data set
to start we will handle Not state on dete_survey to indicate it as null values while reading file
dete_survey=pd.read_csv("dete_survey.csv",na_values="Not Stated")
explore_df(dete_survey,"dete_survey")
dete_survey <class 'pandas.core.frame.DataFrame'> RangeIndex: 822 entries, 0 to 821 Data columns (total 56 columns): ID 822 non-null int64 SeparationType 822 non-null object Cease Date 788 non-null object DETE Start Date 749 non-null float64 Role Start Date 724 non-null float64 Position 817 non-null object Classification 455 non-null object Region 717 non-null object Business Unit 126 non-null object Employment Status 817 non-null object Career move to public sector 822 non-null bool Career move to private sector 822 non-null bool Interpersonal conflicts 822 non-null bool Job dissatisfaction 822 non-null bool Dissatisfaction with the department 822 non-null bool Physical work environment 822 non-null bool Lack of recognition 822 non-null bool Lack of job security 822 non-null bool Work location 822 non-null bool Employment conditions 822 non-null bool Maternity/family 822 non-null bool Relocation 822 non-null bool Study/Travel 822 non-null bool Ill Health 822 non-null bool Traumatic incident 822 non-null bool Work life balance 822 non-null bool Workload 822 non-null bool None of the above 822 non-null bool Professional Development 808 non-null object Opportunities for promotion 735 non-null object Staff morale 816 non-null object Workplace issue 788 non-null object Physical environment 817 non-null object Worklife balance 815 non-null object Stress and pressure support 810 non-null object Performance of supervisor 813 non-null object Peer support 812 non-null object Initiative 813 non-null object Skills 811 non-null object Coach 767 non-null object Career Aspirations 746 non-null object Feedback 792 non-null object Further PD 768 non-null object Communication 814 non-null object My say 812 non-null object Information 816 non-null object Kept informed 813 non-null object Wellness programs 766 non-null object Health & Safety 793 non-null object Gender 798 non-null object Age 811 non-null object Aboriginal 16 non-null object Torres Strait 3 non-null object South Sea 7 non-null object Disability 23 non-null object NESB 32 non-null object dtypes: bool(18), float64(2), int64(1), object(35) memory usage: 258.6+ KB None top 5 ID SeparationType Cease Date DETE Start Date \ 0 1 Ill Health Retirement 08/2012 1984.0 1 2 Voluntary Early Retirement (VER) 08/2012 NaN 2 3 Voluntary Early Retirement (VER) 05/2012 2011.0 3 4 Resignation-Other reasons 05/2012 2005.0 4 5 Age Retirement 05/2012 1970.0 Role Start Date Position \ 0 2004.0 Public Servant 1 NaN Public Servant 2 2011.0 Schools Officer 3 2006.0 Teacher 4 1989.0 Head of Curriculum/Head of Special Education Classification Region Business Unit \ 0 A01-A04 Central Office Corporate Strategy and Peformance 1 AO5-AO7 Central Office Corporate Strategy and Peformance 2 NaN Central Office Education Queensland 3 Primary Central Queensland NaN 4 NaN South East NaN Employment Status ... Kept informed Wellness programs \ 0 Permanent Full-time ... N N 1 Permanent Full-time ... N N 2 Permanent Full-time ... N N 3 Permanent Full-time ... A N 4 Permanent Full-time ... N A Health & Safety Gender Age Aboriginal Torres Strait South Sea \ 0 N Male 56-60 NaN NaN NaN 1 N Male 56-60 NaN NaN NaN 2 N Male 61 or older NaN NaN NaN 3 A Female 36-40 NaN NaN NaN 4 M Female 61 or older NaN NaN NaN Disability NESB 0 NaN Yes 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 NaN NaN [5 rows x 56 columns] first rows ID 1 SeparationType Ill Health Retirement Cease Date 08/2012 DETE Start Date 1984 Role Start Date 2004 Position Public Servant Classification A01-A04 Region Central Office Business Unit Corporate Strategy and Peformance Employment Status Permanent Full-time Career move to public sector True Career move to private sector False Interpersonal conflicts False Job dissatisfaction True Dissatisfaction with the department False Physical work environment False Lack of recognition True Lack of job security False Work location False Employment conditions False Maternity/family False Relocation False Study/Travel False Ill Health False Traumatic incident False Work life balance False Workload False None of the above True Professional Development A Opportunities for promotion A Staff morale N Workplace issue N Physical environment N Worklife balance A Stress and pressure support A Performance of supervisor A Peer support A Initiative N Skills N Coach N Career Aspirations A Feedback A Further PD A Communication N My say A Information A Kept informed N Wellness programs N Health & Safety N Gender Male Age 56-60 Aboriginal NaN Torres Strait NaN South Sea NaN Disability NaN NESB Yes Name: 0, dtype: object descibe data ID DETE Start Date Role Start Date count 822.000000 749.000000 724.000000 mean 411.693431 1994.182911 1998.955801 std 237.705820 13.880503 67.792281 min 1.000000 1963.000000 200.000000 25% 206.250000 1982.000000 1995.000000 50% 411.500000 1996.000000 2005.000000 75% 616.750000 2007.000000 2010.000000 max 823.000000 2013.000000 2013.000000 null values ID 0 SeparationType 0 Cease Date 34 DETE Start Date 73 Role Start Date 98 Position 5 Classification 367 Region 105 Business Unit 696 Employment Status 5 Career move to public sector 0 Career move to private sector 0 Interpersonal conflicts 0 Job dissatisfaction 0 Dissatisfaction with the department 0 Physical work environment 0 Lack of recognition 0 Lack of job security 0 Work location 0 Employment conditions 0 Maternity/family 0 Relocation 0 Study/Travel 0 Ill Health 0 Traumatic incident 0 Work life balance 0 Workload 0 None of the above 0 Professional Development 14 Opportunities for promotion 87 Staff morale 6 Workplace issue 34 Physical environment 5 Worklife balance 7 Stress and pressure support 12 Performance of supervisor 9 Peer support 10 Initiative 9 Skills 11 Coach 55 Career Aspirations 76 Feedback 30 Further PD 54 Communication 8 My say 10 Information 6 Kept informed 9 Wellness programs 56 Health & Safety 29 Gender 24 Age 11 Aboriginal 806 Torres Strait 819 South Sea 815 Disability 799 NESB 790 dtype: int64
print(dete_survey.columns[28:49])
Index(['Professional Development', 'Opportunities for promotion', 'Staff morale', 'Workplace issue', 'Physical environment', 'Worklife balance', 'Stress and pressure support', 'Performance of supervisor', 'Peer support', 'Initiative', 'Skills', 'Coach', 'Career Aspirations', 'Feedback', 'Further PD', 'Communication', 'My say', 'Information', 'Kept informed', 'Wellness programs', 'Health & Safety'], dtype='object')
# drop unneeded column in dete_survey by columns index [28:49]
dete_survey_updated=dete_survey.drop(dete_survey.columns[28:49],axis=1)
# explore dete_survey_updated after dropping unneeded columns
explore_df(dete_survey_updated,"dete_survey_updated")
dete_survey_updated <class 'pandas.core.frame.DataFrame'> RangeIndex: 822 entries, 0 to 821 Data columns (total 35 columns): ID 822 non-null int64 SeparationType 822 non-null object Cease Date 788 non-null object DETE Start Date 749 non-null float64 Role Start Date 724 non-null float64 Position 817 non-null object Classification 455 non-null object Region 717 non-null object Business Unit 126 non-null object Employment Status 817 non-null object Career move to public sector 822 non-null bool Career move to private sector 822 non-null bool Interpersonal conflicts 822 non-null bool Job dissatisfaction 822 non-null bool Dissatisfaction with the department 822 non-null bool Physical work environment 822 non-null bool Lack of recognition 822 non-null bool Lack of job security 822 non-null bool Work location 822 non-null bool Employment conditions 822 non-null bool Maternity/family 822 non-null bool Relocation 822 non-null bool Study/Travel 822 non-null bool Ill Health 822 non-null bool Traumatic incident 822 non-null bool Work life balance 822 non-null bool Workload 822 non-null bool None of the above 822 non-null bool Gender 798 non-null object Age 811 non-null object Aboriginal 16 non-null object Torres Strait 3 non-null object South Sea 7 non-null object Disability 23 non-null object NESB 32 non-null object dtypes: bool(18), float64(2), int64(1), object(14) memory usage: 123.7+ KB None top 5 ID SeparationType Cease Date DETE Start Date \ 0 1 Ill Health Retirement 08/2012 1984.0 1 2 Voluntary Early Retirement (VER) 08/2012 NaN 2 3 Voluntary Early Retirement (VER) 05/2012 2011.0 3 4 Resignation-Other reasons 05/2012 2005.0 4 5 Age Retirement 05/2012 1970.0 Role Start Date Position \ 0 2004.0 Public Servant 1 NaN Public Servant 2 2011.0 Schools Officer 3 2006.0 Teacher 4 1989.0 Head of Curriculum/Head of Special Education Classification Region Business Unit \ 0 A01-A04 Central Office Corporate Strategy and Peformance 1 AO5-AO7 Central Office Corporate Strategy and Peformance 2 NaN Central Office Education Queensland 3 Primary Central Queensland NaN 4 NaN South East NaN Employment Status ... Work life balance Workload None of the above \ 0 Permanent Full-time ... False False True 1 Permanent Full-time ... False False False 2 Permanent Full-time ... False False True 3 Permanent Full-time ... False False False 4 Permanent Full-time ... True False False Gender Age Aboriginal Torres Strait South Sea Disability NESB 0 Male 56-60 NaN NaN NaN NaN Yes 1 Male 56-60 NaN NaN NaN NaN NaN 2 Male 61 or older NaN NaN NaN NaN NaN 3 Female 36-40 NaN NaN NaN NaN NaN 4 Female 61 or older NaN NaN NaN NaN NaN [5 rows x 35 columns] first rows ID 1 SeparationType Ill Health Retirement Cease Date 08/2012 DETE Start Date 1984 Role Start Date 2004 Position Public Servant Classification A01-A04 Region Central Office Business Unit Corporate Strategy and Peformance Employment Status Permanent Full-time Career move to public sector True Career move to private sector False Interpersonal conflicts False Job dissatisfaction True Dissatisfaction with the department False Physical work environment False Lack of recognition True Lack of job security False Work location False Employment conditions False Maternity/family False Relocation False Study/Travel False Ill Health False Traumatic incident False Work life balance False Workload False None of the above True Gender Male Age 56-60 Aboriginal NaN Torres Strait NaN South Sea NaN Disability NaN NESB Yes Name: 0, dtype: object descibe data ID DETE Start Date Role Start Date count 822.000000 749.000000 724.000000 mean 411.693431 1994.182911 1998.955801 std 237.705820 13.880503 67.792281 min 1.000000 1963.000000 200.000000 25% 206.250000 1982.000000 1995.000000 50% 411.500000 1996.000000 2005.000000 75% 616.750000 2007.000000 2010.000000 max 823.000000 2013.000000 2013.000000 null values ID 0 SeparationType 0 Cease Date 34 DETE Start Date 73 Role Start Date 98 Position 5 Classification 367 Region 105 Business Unit 696 Employment Status 5 Career move to public sector 0 Career move to private sector 0 Interpersonal conflicts 0 Job dissatisfaction 0 Dissatisfaction with the department 0 Physical work environment 0 Lack of recognition 0 Lack of job security 0 Work location 0 Employment conditions 0 Maternity/family 0 Relocation 0 Study/Travel 0 Ill Health 0 Traumatic incident 0 Work life balance 0 Workload 0 None of the above 0 Gender 24 Age 11 Aboriginal 806 Torres Strait 819 South Sea 815 Disability 799 NESB 790 dtype: int64
print(tafe_survey.columns[17:66])
Index(['Main Factor. Which of these was the main factor for leaving?', 'InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction', 'InstituteViews. Topic:2. I was given access to skills training to help me do my job better', 'InstituteViews. Topic:3. I was given adequate opportunities for personal development', 'InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL%', 'InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had', 'InstituteViews. Topic:6. The organisation recognised when staff did good work', 'InstituteViews. Topic:7. Management was generally supportive of me', 'InstituteViews. Topic:8. Management was generally supportive of my team', 'InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me', 'InstituteViews. Topic:10. Staff morale was positive within the Institute', 'InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly', 'InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently', 'InstituteViews. Topic:13. If I had a workplace issue it was dealt with discreetly', 'WorkUnitViews. Topic:14. I was satisfied with the quality of the management and supervision within my work unit', 'WorkUnitViews. Topic:15. I worked well with my colleagues', 'WorkUnitViews. Topic:16. My job was challenging and interesting', 'WorkUnitViews. Topic:17. I was encouraged to use my initiative in the course of my work', 'WorkUnitViews. Topic:18. I had sufficient contact with other people in my job', 'WorkUnitViews. Topic:19. I was given adequate support and co-operation by my peers to enable me to do my job', 'WorkUnitViews. Topic:20. I was able to use the full range of my skills in my job', 'WorkUnitViews. Topic:21. I was able to use the full range of my abilities in my job. ; Category:Level of Agreement; Question:YOUR VIEWS ABOUT YOUR WORK UNIT]', 'WorkUnitViews. Topic:22. I was able to use the full range of my knowledge in my job', 'WorkUnitViews. Topic:23. My job provided sufficient variety', 'WorkUnitViews. Topic:24. I was able to cope with the level of stress and pressure in my job', 'WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction', 'WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance', 'WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area', 'WorkUnitViews. Topic:28. I was given the opportunity to mentor and coach others in order for me to pass on my skills and knowledge prior to my cessation date', 'WorkUnitViews. Topic:29. There was adequate communication between staff in my unit', 'WorkUnitViews. Topic:30. Staff morale was positive within my work unit', 'Induction. Did you undertake Workplace Induction?', 'InductionInfo. Topic:Did you undertake a Corporate Induction?', 'InductionInfo. Topic:Did you undertake a Institute Induction?', 'InductionInfo. Topic: Did you undertake Team Induction?', 'InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted?', 'InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted?', 'InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction?', 'InductionInfo. Face to Face Topic:Did you undertake a Institute Induction?', 'InductionInfo. On-line Topic:Did you undertake a Institute Induction?', 'InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction?', 'InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category?', 'InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.]', 'InductionInfo. Induction Manual Topic: Did you undertake Team Induction?', 'Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)?', 'Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination?', 'Workplace. Topic:Does your workplace promote and practice the principles of employment equity?', 'Workplace. Topic:Does your workplace value the diversity of its employees?', 'Workplace. Topic:Would you recommend the Institute as an employer to others?'], dtype='object')
# drop unneeded columns in tafe_survey using columns index [17:66]
tafe_survey_updated=tafe_survey.drop(tafe_survey.columns[17:66],axis=1)
# explore tafe_survey after dropping unneeded columns
explore_df(tafe_survey_updated,"tafe_survey_updated")
tafe_survey_updated <class 'pandas.core.frame.DataFrame'> RangeIndex: 702 entries, 0 to 701 Data columns (total 23 columns): Record ID 702 non-null float64 Institute 702 non-null object WorkArea 702 non-null object CESSATION YEAR 695 non-null float64 Reason for ceasing employment 701 non-null object Contributing Factors. Career Move - Public Sector 437 non-null object Contributing Factors. Career Move - Private Sector 437 non-null object Contributing Factors. Career Move - Self-employment 437 non-null object Contributing Factors. Ill Health 437 non-null object Contributing Factors. Maternity/Family 437 non-null object Contributing Factors. Dissatisfaction 437 non-null object Contributing Factors. Job Dissatisfaction 437 non-null object Contributing Factors. Interpersonal Conflict 437 non-null object Contributing Factors. Study 437 non-null object Contributing Factors. Travel 437 non-null object Contributing Factors. Other 437 non-null object Contributing Factors. NONE 437 non-null object Gender. What is your Gender? 596 non-null object CurrentAge. Current Age 596 non-null object Employment Type. Employment Type 596 non-null object Classification. Classification 596 non-null object LengthofServiceOverall. Overall Length of Service at Institute (in years) 596 non-null object LengthofServiceCurrent. Length of Service at current workplace (in years) 596 non-null object dtypes: float64(2), object(21) memory usage: 126.2+ KB None top 5 Record ID Institute \ 0 6.341330e+17 Southern Queensland Institute of TAFE 1 6.341337e+17 Mount Isa Institute of TAFE 2 6.341388e+17 Mount Isa Institute of TAFE 3 6.341399e+17 Mount Isa Institute of TAFE 4 6.341466e+17 Southern Queensland Institute of TAFE WorkArea CESSATION YEAR Reason for ceasing employment \ 0 Non-Delivery (corporate) 2010.0 Contract Expired 1 Non-Delivery (corporate) 2010.0 Retirement 2 Delivery (teaching) 2010.0 Retirement 3 Non-Delivery (corporate) 2010.0 Resignation 4 Delivery (teaching) 2010.0 Resignation Contributing Factors. Career Move - Public Sector \ 0 NaN 1 - 2 - 3 - 4 - Contributing Factors. Career Move - Private Sector \ 0 NaN 1 - 2 - 3 - 4 Career Move - Private Sector Contributing Factors. Career Move - Self-employment \ 0 NaN 1 - 2 - 3 - 4 - Contributing Factors. Ill Health Contributing Factors. Maternity/Family \ 0 NaN NaN 1 - - 2 - - 3 - - 4 - - ... \ 0 ... 1 ... 2 ... 3 ... 4 ... Contributing Factors. Study Contributing Factors. Travel \ 0 NaN NaN 1 - Travel 2 - - 3 - Travel 4 - - Contributing Factors. Other Contributing Factors. NONE \ 0 NaN NaN 1 - - 2 - NONE 3 - - 4 - - Gender. What is your Gender? CurrentAge. Current Age \ 0 Female 26 30 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 Male 41 45 Employment Type. Employment Type Classification. Classification \ 0 Temporary Full-time Administration (AO) 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 Permanent Full-time Teacher (including LVT) LengthofServiceOverall. Overall Length of Service at Institute (in years) \ 0 1-2 1 NaN 2 NaN 3 NaN 4 3-4 LengthofServiceCurrent. Length of Service at current workplace (in years) 0 1-2 1 NaN 2 NaN 3 NaN 4 3-4 [5 rows x 23 columns] first rows Record ID 6.34133e+17 Institute Southern Queensland Institute of TAFE WorkArea Non-Delivery (corporate) CESSATION YEAR 2010 Reason for ceasing employment Contract Expired Contributing Factors. Career Move - Public Sector NaN Contributing Factors. Career Move - Private Sector NaN Contributing Factors. Career Move - Self-employment NaN Contributing Factors. Ill Health NaN Contributing Factors. Maternity/Family NaN Contributing Factors. Dissatisfaction NaN Contributing Factors. Job Dissatisfaction NaN Contributing Factors. Interpersonal Conflict NaN Contributing Factors. Study NaN Contributing Factors. Travel NaN Contributing Factors. Other NaN Contributing Factors. NONE NaN Gender. What is your Gender? Female CurrentAge. Current Age 26 30 Employment Type. Employment Type Temporary Full-time Classification. Classification Administration (AO) LengthofServiceOverall. Overall Length of Service at Institute (in years) 1-2 LengthofServiceCurrent. Length of Service at current workplace (in years) 1-2 Name: 0, dtype: object descibe data Record ID CESSATION YEAR count 7.020000e+02 695.000000 mean 6.346026e+17 2011.423022 std 2.515071e+14 0.905977 min 6.341330e+17 2009.000000 25% 6.343954e+17 2011.000000 50% 6.345835e+17 2011.000000 75% 6.348005e+17 2012.000000 max 6.350730e+17 2013.000000 null values Record ID 0 Institute 0 WorkArea 0 CESSATION YEAR 7 Reason for ceasing employment 1 Contributing Factors. Career Move - Public Sector 265 Contributing Factors. Career Move - Private Sector 265 Contributing Factors. Career Move - Self-employment 265 Contributing Factors. Ill Health 265 Contributing Factors. Maternity/Family 265 Contributing Factors. Dissatisfaction 265 Contributing Factors. Job Dissatisfaction 265 Contributing Factors. Interpersonal Conflict 265 Contributing Factors. Study 265 Contributing Factors. Travel 265 Contributing Factors. Other 265 Contributing Factors. NONE 265 Gender. What is your Gender? 106 CurrentAge. Current Age 106 Employment Type. Employment Type 106 Classification. Classification 106 LengthofServiceOverall. Overall Length of Service at Institute (in years) 106 LengthofServiceCurrent. Length of Service at current workplace (in years) 106 dtype: int64
after removing unneeded columns in both dataset as they are not realted to questions which is the project goal: - Are employees who only worked for the institutes for a short period of time resigning due to some kind of dissatisfaction? What about employees who have been there longer? - Are younger employees resigning due to some kind of dissatisfaction? What about older employees? we find dete_survey_updated now have 35 column & tafe_survey now have 23 columns _______________________
# rename dete_survey_updated columns
dete_survey_updated.columns=dete_survey_updated.columns.str.lower().str.strip().str.replace(" ","_")
print(dete_survey_updated.columns)
Index(['id', 'separationtype', 'cease_date', 'dete_start_date', 'role_start_date', 'position', 'classification', 'region', 'business_unit', 'employment_status', 'career_move_to_public_sector', 'career_move_to_private_sector', 'interpersonal_conflicts', 'job_dissatisfaction', 'dissatisfaction_with_the_department', 'physical_work_environment', 'lack_of_recognition', 'lack_of_job_security', 'work_location', 'employment_conditions', 'maternity/family', 'relocation', 'study/travel', 'ill_health', 'traumatic_incident', 'work_life_balance', 'workload', 'none_of_the_above', 'gender', 'age', 'aboriginal', 'torres_strait', 'south_sea', 'disability', 'nesb'], dtype='object')
# rename columns in tafe_survey which is similar to dete_survey with same name
mapping={'Record ID': 'id','CESSATION YEAR': 'cease_date','Reason for ceasing employment': 'separationtype',
'Gender. What is your Gender?': 'gender','CurrentAge. Current Age': 'age','Employment Type. Employment Type': 'employment_status',
'Classification. Classification': 'position','LengthofServiceOverall. Overall Length of Service at Institute (in years)': 'institute_service',
'LengthofServiceCurrent. Length of Service at current workplace (in years)': 'role_service'}
tafe_survey_updated.rename(columns=mapping,inplace=True)
print(tafe_survey_updated.columns)
Index(['id', 'Institute', 'WorkArea', 'cease_date', 'separationtype', 'Contributing Factors. Career Move - Public Sector ', 'Contributing Factors. Career Move - Private Sector ', 'Contributing Factors. Career Move - Self-employment', 'Contributing Factors. Ill Health', 'Contributing Factors. Maternity/Family', 'Contributing Factors. Dissatisfaction', 'Contributing Factors. Job Dissatisfaction', 'Contributing Factors. Interpersonal Conflict', 'Contributing Factors. Study', 'Contributing Factors. Travel', 'Contributing Factors. Other', 'Contributing Factors. NONE', 'gender', 'age', 'employment_status', 'position', 'institute_service', 'role_service'], dtype='object')
# create unique_val()function to check unique columns data
def unique_val(df,col):
print(df[col].value_counts().sort_index(ascending=False))
# check unique value in separationtype for dete_survey_updated dataset
unique_val(dete_survey_updated,"separationtype")
Voluntary Early Retirement (VER) 67 Termination 15 Resignation-Other reasons 150 Resignation-Other employer 91 Resignation-Move overseas/interstate 70 Other 49 Ill Health Retirement 61 Contract Expired 34 Age Retirement 285 Name: separationtype, dtype: int64
# check unique value in separationtype for tafe_survey_updated dataset
unique_val(tafe_survey_updated,"separationtype")
Transfer 25 Termination 23 Retrenchment/ Redundancy 104 Retirement 82 Resignation 340 Contract Expired 127 Name: separationtype, dtype: int64
so, we will work only on separationtype have Resignation reason
# count all Resignation type in dete_survey_dataset by renaming it to Resignation
dete_survey_updated["separationtype"]=dete_survey_updated["separationtype"].str.split("-").str[0]
unique_val(dete_survey_updated,"separationtype")
Voluntary Early Retirement (VER) 67 Termination 15 Resignation 311 Other 49 Ill Health Retirement 61 Contract Expired 34 Age Retirement 285 Name: separationtype, dtype: int64
# will work only on Resignation data , make copy from it
dete_resignations=dete_survey_updated[dete_survey_updated["separationtype"]=="Resignation"].copy()
explore_df(dete_resignations,"dete_resignation")
dete_resignation <class 'pandas.core.frame.DataFrame'> Int64Index: 311 entries, 3 to 821 Data columns (total 35 columns): id 311 non-null int64 separationtype 311 non-null object cease_date 300 non-null object dete_start_date 283 non-null float64 role_start_date 271 non-null float64 position 308 non-null object classification 161 non-null object region 265 non-null object business_unit 32 non-null object employment_status 307 non-null object career_move_to_public_sector 311 non-null bool career_move_to_private_sector 311 non-null bool interpersonal_conflicts 311 non-null bool job_dissatisfaction 311 non-null bool dissatisfaction_with_the_department 311 non-null bool physical_work_environment 311 non-null bool lack_of_recognition 311 non-null bool lack_of_job_security 311 non-null bool work_location 311 non-null bool employment_conditions 311 non-null bool maternity/family 311 non-null bool relocation 311 non-null bool study/travel 311 non-null bool ill_health 311 non-null bool traumatic_incident 311 non-null bool work_life_balance 311 non-null bool workload 311 non-null bool none_of_the_above 311 non-null bool gender 302 non-null object age 306 non-null object aboriginal 7 non-null object torres_strait 0 non-null object south_sea 3 non-null object disability 8 non-null object nesb 9 non-null object dtypes: bool(18), float64(2), int64(1), object(14) memory usage: 49.2+ KB None top 5 id separationtype cease_date dete_start_date role_start_date \ 3 4 Resignation 05/2012 2005.0 2006.0 5 6 Resignation 05/2012 1994.0 1997.0 8 9 Resignation 07/2012 2009.0 2009.0 9 10 Resignation 2012 1997.0 2008.0 11 12 Resignation 2012 2009.0 2009.0 position classification region \ 3 Teacher Primary Central Queensland 5 Guidance Officer NaN Central Office 8 Teacher Secondary North Queensland 9 Teacher Aide NaN NaN 11 Teacher Secondary Far North Queensland business_unit employment_status ... work_life_balance \ 3 NaN Permanent Full-time ... False 5 Education Queensland Permanent Full-time ... False 8 NaN Permanent Full-time ... False 9 NaN Permanent Part-time ... False 11 NaN Permanent Full-time ... False workload none_of_the_above gender age aboriginal torres_strait \ 3 False False Female 36-40 NaN NaN 5 False False Female 41-45 NaN NaN 8 False False Female 31-35 NaN NaN 9 False False Female 46-50 NaN NaN 11 False False Male 31-35 NaN NaN south_sea disability nesb 3 NaN NaN NaN 5 NaN NaN NaN 8 NaN NaN NaN 9 NaN NaN NaN 11 NaN NaN NaN [5 rows x 35 columns] first rows id 4 separationtype Resignation cease_date 05/2012 dete_start_date 2005 role_start_date 2006 position Teacher classification Primary region Central Queensland business_unit NaN employment_status Permanent Full-time career_move_to_public_sector False career_move_to_private_sector True interpersonal_conflicts False job_dissatisfaction False dissatisfaction_with_the_department False physical_work_environment False lack_of_recognition False lack_of_job_security False work_location False employment_conditions False maternity/family False relocation False study/travel False ill_health False traumatic_incident False work_life_balance False workload False none_of_the_above False gender Female age 36-40 aboriginal NaN torres_strait NaN south_sea NaN disability NaN nesb NaN Name: 3, dtype: object descibe data id dete_start_date role_start_date count 311.000000 283.000000 271.000000 mean 427.739550 2002.067138 1999.653137 std 235.028398 9.914479 109.965675 min 4.000000 1963.000000 200.000000 25% 256.500000 1997.000000 2004.000000 50% 434.000000 2005.000000 2009.000000 75% 626.500000 2010.000000 2011.000000 max 823.000000 2013.000000 2013.000000 null values id 0 separationtype 0 cease_date 11 dete_start_date 28 role_start_date 40 position 3 classification 150 region 46 business_unit 279 employment_status 4 career_move_to_public_sector 0 career_move_to_private_sector 0 interpersonal_conflicts 0 job_dissatisfaction 0 dissatisfaction_with_the_department 0 physical_work_environment 0 lack_of_recognition 0 lack_of_job_security 0 work_location 0 employment_conditions 0 maternity/family 0 relocation 0 study/travel 0 ill_health 0 traumatic_incident 0 work_life_balance 0 workload 0 none_of_the_above 0 gender 9 age 5 aboriginal 304 torres_strait 311 south_sea 308 disability 303 nesb 302 dtype: int64
tafe_resignations=tafe_survey_updated[tafe_survey_updated["separationtype"]=="Resignation"].copy()
explore_df(tafe_resignations,"tafe_resignation")
tafe_resignation <class 'pandas.core.frame.DataFrame'> Int64Index: 340 entries, 3 to 701 Data columns (total 23 columns): id 340 non-null float64 Institute 340 non-null object WorkArea 340 non-null object cease_date 335 non-null float64 separationtype 340 non-null object Contributing Factors. Career Move - Public Sector 332 non-null object Contributing Factors. Career Move - Private Sector 332 non-null object Contributing Factors. Career Move - Self-employment 332 non-null object Contributing Factors. Ill Health 332 non-null object Contributing Factors. Maternity/Family 332 non-null object Contributing Factors. Dissatisfaction 332 non-null object Contributing Factors. Job Dissatisfaction 332 non-null object Contributing Factors. Interpersonal Conflict 332 non-null object Contributing Factors. Study 332 non-null object Contributing Factors. Travel 332 non-null object Contributing Factors. Other 332 non-null object Contributing Factors. NONE 332 non-null object gender 290 non-null object age 290 non-null object employment_status 290 non-null object position 290 non-null object institute_service 290 non-null object role_service 290 non-null object dtypes: float64(2), object(21) memory usage: 63.8+ KB None top 5 id Institute \ 3 6.341399e+17 Mount Isa Institute of TAFE 4 6.341466e+17 Southern Queensland Institute of TAFE 5 6.341475e+17 Southern Queensland Institute of TAFE 6 6.341520e+17 Barrier Reef Institute of TAFE 7 6.341537e+17 Southern Queensland Institute of TAFE WorkArea cease_date separationtype \ 3 Non-Delivery (corporate) 2010.0 Resignation 4 Delivery (teaching) 2010.0 Resignation 5 Delivery (teaching) 2010.0 Resignation 6 Non-Delivery (corporate) 2010.0 Resignation 7 Delivery (teaching) 2010.0 Resignation Contributing Factors. Career Move - Public Sector \ 3 - 4 - 5 - 6 - 7 - Contributing Factors. Career Move - Private Sector \ 3 - 4 Career Move - Private Sector 5 - 6 Career Move - Private Sector 7 - Contributing Factors. Career Move - Self-employment \ 3 - 4 - 5 - 6 - 7 - Contributing Factors. Ill Health Contributing Factors. Maternity/Family \ 3 - - 4 - - 5 - - 6 - Maternity/Family 7 - - ... Contributing Factors. Study Contributing Factors. Travel \ 3 ... - Travel 4 ... - - 5 ... - - 6 ... - - 7 ... - - Contributing Factors. Other Contributing Factors. NONE gender \ 3 - - NaN 4 - - Male 5 Other - Female 6 Other - Male 7 Other - Male age employment_status position \ 3 NaN NaN NaN 4 41 45 Permanent Full-time Teacher (including LVT) 5 56 or older Contract/casual Teacher (including LVT) 6 20 or younger Temporary Full-time Administration (AO) 7 46 50 Permanent Full-time Teacher (including LVT) institute_service role_service 3 NaN NaN 4 3-4 3-4 5 7-10 7-10 6 3-4 3-4 7 3-4 3-4 [5 rows x 23 columns] first rows id 6.3414e+17 Institute Mount Isa Institute of TAFE WorkArea Non-Delivery (corporate) cease_date 2010 separationtype Resignation Contributing Factors. Career Move - Public Sector - Contributing Factors. Career Move - Private Sector - Contributing Factors. Career Move - Self-employment - Contributing Factors. Ill Health - Contributing Factors. Maternity/Family - Contributing Factors. Dissatisfaction - Contributing Factors. Job Dissatisfaction - Contributing Factors. Interpersonal Conflict - Contributing Factors. Study - Contributing Factors. Travel Travel Contributing Factors. Other - Contributing Factors. NONE - gender NaN age NaN employment_status NaN position NaN institute_service NaN role_service NaN Name: 3, dtype: object descibe data id cease_date count 3.400000e+02 335.000000 mean 6.345843e+17 2011.394030 std 2.813969e+14 1.005952 min 6.341399e+17 2009.000000 25% 6.343257e+17 2011.000000 50% 6.345693e+17 2011.000000 75% 6.348252e+17 2012.000000 max 6.350730e+17 2013.000000 null values id 0 Institute 0 WorkArea 0 cease_date 5 separationtype 0 Contributing Factors. Career Move - Public Sector 8 Contributing Factors. Career Move - Private Sector 8 Contributing Factors. Career Move - Self-employment 8 Contributing Factors. Ill Health 8 Contributing Factors. Maternity/Family 8 Contributing Factors. Dissatisfaction 8 Contributing Factors. Job Dissatisfaction 8 Contributing Factors. Interpersonal Conflict 8 Contributing Factors. Study 8 Contributing Factors. Travel 8 Contributing Factors. Other 8 Contributing Factors. NONE 8 gender 50 age 50 employment_status 50 position 50 institute_service 50 role_service 50 dtype: int64
# check separationtype
unique_val(dete_resignations,"separationtype")
unique_val(tafe_resignations,"separationtype")
Resignation 311 Name: separationtype, dtype: int64 Resignation 340 Name: separationtype, dtype: int64
on dete_resignations we have columns [cease_date, dete_start_date] we need be sure that:
1- dete_start_date not after cease_date.
2- Given that most people in this field start working in their 20s, it's also unlikely that the dete_start_date was before the year 1940.
3- If there are a small amount of values that are unrealistically high or low, we can remove them.
so now we will proceed:
# check cease_date in dete_resginations by using value_counts in unique_val() function we have created it above to check unique values
unique_val(dete_resignations,"cease_date")
2013 74 2012 126 2010 1 12/2013 17 11/2013 9 10/2013 6 09/2013 11 09/2010 1 08/2013 4 07/2013 9 07/2012 1 07/2006 1 06/2013 14 05/2013 2 05/2012 2 01/2014 22 Name: cease_date, dtype: int64
# make [cease_year]columns contain only the year and convert it to float
pattern=r"([1-2][0-9]{3})"
dete_resignations["cease_year"]=dete_resignations["cease_date"].str.extract(pattern,expand=True).astype("float")
unique_val(dete_resignations,"cease_year")
print(dete_resignations["cease_year"].dtype)
2014.0 22 2013.0 146 2012.0 129 2010.0 2 2006.0 1 Name: cease_year, dtype: int64 float64
# check dete_start_date in dete_resignations by using value_counts in unique_val() function we have created it above to check unique values
unique_val(dete_resignations,"dete_start_date")
print(min(dete_resignations["dete_start_date"]),max(dete_resignations["dete_start_date"]))
2013.0 10 2012.0 21 2011.0 24 2010.0 17 2009.0 13 2008.0 22 2007.0 21 2006.0 13 2005.0 15 2004.0 14 2003.0 6 2002.0 6 2001.0 3 2000.0 9 1999.0 8 1998.0 6 1997.0 5 1996.0 6 1995.0 4 1994.0 6 1993.0 5 1992.0 6 1991.0 4 1990.0 5 1989.0 4 1988.0 4 1987.0 1 1986.0 3 1985.0 3 1984.0 1 1983.0 2 1982.0 1 1980.0 5 1977.0 1 1976.0 2 1975.0 1 1974.0 2 1973.0 1 1972.0 1 1971.0 1 1963.0 1 Name: dete_start_date, dtype: int64 1963.0 2013.0
# check cease_date on tafe_resignations by using value_counts in unique_val() function we have created it above to check unique values
unique_val(tafe_resignations,"cease_date")
2013.0 55 2012.0 94 2011.0 116 2010.0 68 2009.0 2 Name: cease_date, dtype: int64
let us plot all these three columns with boxplot to identify any values that look wrong.
fig=plt.figure()
<matplotlib.figure.Figure at 0x7f25144c3f98>
years_columns=["dete_start_date","cease_year"]
dete_resignations.boxplot(column=years_columns)
<matplotlib.axes._subplots.AxesSubplot at 0x7f2514c61c88>
# fig=plt.figure()
ax=tafe_resignations.boxplot(column=["cease_date"])
ax.set_ylim(1990,2020)
(1990, 2020)
# Calculate the length of time an employee spent in their respective workplace and create a new column
dete_resignations["institute_service"]=dete_resignations["cease_year"]-dete_resignations["dete_start_date"]
# Quick check of the result
unique_val(dete_resignations,"institute_service")
49.0 1 42.0 1 41.0 1 39.0 3 38.0 1 36.0 2 35.0 1 34.0 1 33.0 1 32.0 3 31.0 1 30.0 2 29.0 1 28.0 2 27.0 1 26.0 2 25.0 2 24.0 4 23.0 4 22.0 6 21.0 3 20.0 7 19.0 3 18.0 5 17.0 6 16.0 5 15.0 7 14.0 6 13.0 8 12.0 6 11.0 4 10.0 6 9.0 14 8.0 8 7.0 13 6.0 17 5.0 23 4.0 16 3.0 20 2.0 14 1.0 22 0.0 20 Name: institute_service, dtype: int64
unique_val(tafe_resignations,"institute_service")
More than 20 years 10 Less than 1 year 73 7-10 21 5-6 33 3-4 63 11-20 26 1-2 64 Name: institute_service, dtype: int64
dete_resignations.boxplot("institute_service")
<matplotlib.axes._subplots.AxesSubplot at 0x7f251465e6d8>
insitute services in dete_resignations range (0,49) years
print(dete_resignations.columns)
Index(['id', 'separationtype', 'cease_date', 'dete_start_date', 'role_start_date', 'position', 'classification', 'region', 'business_unit', 'employment_status', 'career_move_to_public_sector', 'career_move_to_private_sector', 'interpersonal_conflicts', 'job_dissatisfaction', 'dissatisfaction_with_the_department', 'physical_work_environment', 'lack_of_recognition', 'lack_of_job_security', 'work_location', 'employment_conditions', 'maternity/family', 'relocation', 'study/travel', 'ill_health', 'traumatic_incident', 'work_life_balance', 'workload', 'none_of_the_above', 'gender', 'age', 'aboriginal', 'torres_strait', 'south_sea', 'disability', 'nesb', 'cease_year', 'institute_service'], dtype='object')
print(tafe_resignations.columns)
Index(['id', 'Institute', 'WorkArea', 'cease_date', 'separationtype', 'Contributing Factors. Career Move - Public Sector ', 'Contributing Factors. Career Move - Private Sector ', 'Contributing Factors. Career Move - Self-employment', 'Contributing Factors. Ill Health', 'Contributing Factors. Maternity/Family', 'Contributing Factors. Dissatisfaction', 'Contributing Factors. Job Dissatisfaction', 'Contributing Factors. Interpersonal Conflict', 'Contributing Factors. Study', 'Contributing Factors. Travel', 'Contributing Factors. Other', 'Contributing Factors. NONE', 'gender', 'age', 'employment_status', 'position', 'institute_service', 'role_service'], dtype='object')
1- on dete_resignations: we will use these columns - job_dissatisfaction - dissatisfaction_with_the_department - physical_work_environment - lack_of_recognition - lack_of_job_security - work_location - employment_conditions - work_life_balance - workload
2- on tafe_resignations: we will use these columns - Contributing Factors. Dissatisfaction - Contributing Factors. Job Dissatisfaction
unique_val(tafe_resignations,"Contributing Factors. Dissatisfaction")
Contributing Factors. Dissatisfaction 55 - 277 Name: Contributing Factors. Dissatisfaction, dtype: int64
unique_val(tafe_resignations,"Contributing Factors. Job Dissatisfaction")
Job Dissatisfaction 62 - 270 Name: Contributing Factors. Job Dissatisfaction, dtype: int64
1- Convert the values in the 'Contributing Factors. Dissatisfaction' and 'Contributing Factors. Job Dissatisfaction' columns in the tafe_resignations dataframe to True, False, or NaN values.
2- If any of the columns listed above contain a True value, we'll add a True value to a new column named dissatisfied. To accomplish this, we'll use the DataFrame.any() method to do the following:
Return True if any element in the selected columns above is True Return False if none of the elements in the selected columns above is True Return NaN if the value is NaN
create function update_vals that makes the following changes:
- If the value is NaN, return np.nan. You can use the following criteria to check that a value is NaN: pd.isnull(val).
- If the value is '-', return False.
- For any other value, return True.
# update_vals() functions
def update_vals(x):
if x=="-":
return False
elif pd.isnull(x):
return np.nan
else:
return True
# create dissatisfied column
tafe_resignations["dissatisfied"]=tafe_resignations[["Contributing Factors. Dissatisfaction","Contributing Factors. Job Dissatisfaction"]
].applymap(update_vals).any(axis=1,skipna=False)
# create copy
tafe_resignations_up=tafe_resignations.copy()
unique_val(dete_resignations,"job_dissatisfaction")
True 41 False 270 Name: job_dissatisfaction, dtype: int64
# dissatisfactions columns in dete_resignations
dissatisfactions=["job_dissatisfaction","dissatisfaction_with_the_department","physical_work_environment","lack_of_recognition"
,"lack_of_job_security","work_location","employment_conditions","work_life_balance","workload"]
# create dissatisfied column
dete_resignations["dissatisfied"]=dete_resignations[dissatisfactions].any(axis=1,skipna=False)
# create copy
dete_resignations_up=dete_resignations.copy()
# create column institute in dete_resignations_up
dete_resignations_up["institute"]="Dete"
# create column institute in tafe_resignations_up
tafe_resignations_up["institute"]="Tafe"
# combine both datasets using concat() and ignore_index=true
combined=pd.concat([dete_resignations_up,tafe_resignations_up],ignore_index=True)
# drop columns which have less than 500 non null values assigns results to combined_updated
combined_updated=combined.dropna(axis=1,thresh=500).copy()
explore_df(combined_updated,"combined_updated")
combined_updated <class 'pandas.core.frame.DataFrame'> RangeIndex: 651 entries, 0 to 650 Data columns (total 10 columns): age 596 non-null object cease_date 635 non-null object dissatisfied 643 non-null object employment_status 597 non-null object gender 592 non-null object id 651 non-null float64 institute 651 non-null object institute_service 563 non-null object position 598 non-null object separationtype 651 non-null object dtypes: float64(1), object(9) memory usage: 50.9+ KB None top 5 age cease_date dissatisfied employment_status gender id institute \ 0 36-40 05/2012 False Permanent Full-time Female 4.0 Dete 1 41-45 05/2012 True Permanent Full-time Female 6.0 Dete 2 31-35 07/2012 False Permanent Full-time Female 9.0 Dete 3 46-50 2012 True Permanent Part-time Female 10.0 Dete 4 31-35 2012 False Permanent Full-time Male 12.0 Dete institute_service position separationtype 0 7 Teacher Resignation 1 18 Guidance Officer Resignation 2 3 Teacher Resignation 3 15 Teacher Aide Resignation 4 3 Teacher Resignation first rows age 36-40 cease_date 05/2012 dissatisfied False employment_status Permanent Full-time gender Female id 4 institute Dete institute_service 7 position Teacher separationtype Resignation Name: 0, dtype: object descibe data id count 6.510000e+02 mean 3.314265e+17 std 3.172210e+17 min 4.000000e+00 25% 4.525000e+02 50% 6.341820e+17 75% 6.345770e+17 max 6.350730e+17 null values age 55 cease_date 16 dissatisfied 8 employment_status 54 gender 59 id 0 institute 0 institute_service 88 position 53 separationtype 0 dtype: int64
we'll have to clean up the institute_service column.
This column is tricky to clean because it currently contains values in a couple different forms:
we will categorize the values in the institute_service column according to follwing:
# check unique_values
combined_updated["institute_service"].value_counts(dropna=False)
NaN 88 Less than 1 year 73 1-2 64 3-4 63 5-6 33 11-20 26 5.0 23 1.0 22 7-10 21 0.0 20 3.0 20 6.0 17 4.0 16 9.0 14 2.0 14 7.0 13 More than 20 years 10 8.0 8 13.0 8 15.0 7 20.0 7 10.0 6 12.0 6 14.0 6 17.0 6 22.0 6 18.0 5 16.0 5 11.0 4 23.0 4 24.0 4 19.0 3 32.0 3 39.0 3 21.0 3 28.0 2 30.0 2 26.0 2 36.0 2 25.0 2 29.0 1 31.0 1 27.0 1 34.0 1 35.0 1 38.0 1 41.0 1 42.0 1 49.0 1 33.0 1 Name: institute_service, dtype: int64
# convert institue_service to str & extract only num then convert it to float, assign result to institute_service_up
combined_updated["institute_service_up"]=combined_updated["institute_service"].astype("str").str.extract(r"(\d+)",expand=True).astype("float")
# check values after converting
combined_updated["institute_service_up"].value_counts(dropna=False)
1.0 159 NaN 88 3.0 83 5.0 56 7.0 34 11.0 30 0.0 20 20.0 17 6.0 17 4.0 16 9.0 14 2.0 14 13.0 8 8.0 8 15.0 7 22.0 6 10.0 6 17.0 6 14.0 6 12.0 6 16.0 5 18.0 5 24.0 4 23.0 4 21.0 3 39.0 3 32.0 3 19.0 3 36.0 2 30.0 2 25.0 2 26.0 2 28.0 2 42.0 1 29.0 1 35.0 1 27.0 1 41.0 1 49.0 1 38.0 1 34.0 1 33.0 1 31.0 1 Name: institute_service_up, dtype: int64
Create a function that maps each year value to one of the career stages above.
# create carrer_stage() function to map values
def career_stage(x):
if pd.isnull(x):
return np.nan
elif x in range(0,3):
return "New"
elif x in range(3,7):
return "Experienced"
elif x in range(7,11):
return "Established"
else:
return "Veteran"
combined_updated["service_cat"]=combined_updated["institute_service_up"].apply(career_stage)
combined_updated["service_cat"].value_counts(dropna=False)
New 193 Experienced 172 Veteran 136 NaN 88 Established 62 Name: service_cat, dtype: int64
we created a service_cat column, that categorizes employees according to the amount of years spent in their workplace:
working with dissatisfied columns converting null values to false
combined_updated["dissatisfied"].fillna(False,inplace=True)
combined_updated["dissatisfied"].value_counts(dropna=False)
False 411 True 240 Name: dissatisfied, dtype: int64
# Calculate the percentage of employees who resigned due to dissatisfaction in each category
dis_pct=combined_updated.pivot_table(values="dissatisfied",index="service_cat",aggfunc=np.mean)
dis_pct.plot(kind="bar",rot=30)
<matplotlib.axes._subplots.AxesSubplot at 0x7f251486fa20>