{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Clean and Analyze Employee Exit Surveys\n",
    "\n",
    "In this project, we'll clean and analyze exit surveys from employees of the [Department of Education, Training and Employment (DETE)](https://en.wikipedia.org/wiki/Department_of_Education_and_Training_(Queensland)}) and the Technical and Further Education (TAFE) body of the Queensland government in Australia. The TAFE exit survey can be found [here](https://data.gov.au/dataset/ds-qld-89970a3b-182b-41ea-aea2-6f9f17b5907e/details?q=exit%20survey) and the survey for the DETE can be found [here](https://data.gov.au/dataset/ds-qld-fe96ff30-d157-4a81-851d-215f2a0fe26d/details?q=exit%20survey).\n",
    "\n",
    "We'll pretend our stakeholders want us to combine the results for *both* surveys to answer the following question:\n",
    "    \n",
    "   - 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?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction\n",
    "\n",
    "First, we'll read in the datasets and do some initial exporation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>SeparationType</th>\n",
       "      <th>Cease Date</th>\n",
       "      <th>DETE Start Date</th>\n",
       "      <th>Role Start Date</th>\n",
       "      <th>Position</th>\n",
       "      <th>Classification</th>\n",
       "      <th>Region</th>\n",
       "      <th>Business Unit</th>\n",
       "      <th>Employment Status</th>\n",
       "      <th>Career move to public sector</th>\n",
       "      <th>Career move to private sector</th>\n",
       "      <th>Interpersonal conflicts</th>\n",
       "      <th>Job dissatisfaction</th>\n",
       "      <th>Dissatisfaction with the department</th>\n",
       "      <th>Physical work environment</th>\n",
       "      <th>Lack of recognition</th>\n",
       "      <th>Lack of job security</th>\n",
       "      <th>Work location</th>\n",
       "      <th>Employment conditions</th>\n",
       "      <th>Maternity/family</th>\n",
       "      <th>Relocation</th>\n",
       "      <th>Study/Travel</th>\n",
       "      <th>Ill Health</th>\n",
       "      <th>Traumatic incident</th>\n",
       "      <th>Work life balance</th>\n",
       "      <th>Workload</th>\n",
       "      <th>None of the above</th>\n",
       "      <th>Professional Development</th>\n",
       "      <th>Opportunities for promotion</th>\n",
       "      <th>Staff morale</th>\n",
       "      <th>Workplace issue</th>\n",
       "      <th>Physical environment</th>\n",
       "      <th>Worklife balance</th>\n",
       "      <th>Stress and pressure support</th>\n",
       "      <th>Performance of supervisor</th>\n",
       "      <th>Peer support</th>\n",
       "      <th>Initiative</th>\n",
       "      <th>Skills</th>\n",
       "      <th>Coach</th>\n",
       "      <th>Career Aspirations</th>\n",
       "      <th>Feedback</th>\n",
       "      <th>Further PD</th>\n",
       "      <th>Communication</th>\n",
       "      <th>My say</th>\n",
       "      <th>Information</th>\n",
       "      <th>Kept informed</th>\n",
       "      <th>Wellness programs</th>\n",
       "      <th>Health &amp; Safety</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Aboriginal</th>\n",
       "      <th>Torres Strait</th>\n",
       "      <th>South Sea</th>\n",
       "      <th>Disability</th>\n",
       "      <th>NESB</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Ill Health Retirement</td>\n",
       "      <td>08/2012</td>\n",
       "      <td>1984</td>\n",
       "      <td>2004</td>\n",
       "      <td>Public Servant</td>\n",
       "      <td>A01-A04</td>\n",
       "      <td>Central Office</td>\n",
       "      <td>Corporate Strategy and Peformance</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>56-60</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Voluntary Early Retirement (VER)</td>\n",
       "      <td>08/2012</td>\n",
       "      <td>Not Stated</td>\n",
       "      <td>Not Stated</td>\n",
       "      <td>Public Servant</td>\n",
       "      <td>AO5-AO7</td>\n",
       "      <td>Central Office</td>\n",
       "      <td>Corporate Strategy and Peformance</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>56-60</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Voluntary Early Retirement (VER)</td>\n",
       "      <td>05/2012</td>\n",
       "      <td>2011</td>\n",
       "      <td>2011</td>\n",
       "      <td>Schools Officer</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Central Office</td>\n",
       "      <td>Education Queensland</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>61 or older</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Resignation-Other reasons</td>\n",
       "      <td>05/2012</td>\n",
       "      <td>2005</td>\n",
       "      <td>2006</td>\n",
       "      <td>Teacher</td>\n",
       "      <td>Primary</td>\n",
       "      <td>Central Queensland</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>Female</td>\n",
       "      <td>36-40</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Age Retirement</td>\n",
       "      <td>05/2012</td>\n",
       "      <td>1970</td>\n",
       "      <td>1989</td>\n",
       "      <td>Head of Curriculum/Head of Special Education</td>\n",
       "      <td>NaN</td>\n",
       "      <td>South East</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>D</td>\n",
       "      <td>D</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>SA</td>\n",
       "      <td>SA</td>\n",
       "      <td>D</td>\n",
       "      <td>D</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "      <td>Female</td>\n",
       "      <td>61 or older</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ID                    SeparationType Cease Date DETE Start Date  \\\n",
       "0   1             Ill Health Retirement    08/2012            1984   \n",
       "1   2  Voluntary Early Retirement (VER)    08/2012      Not Stated   \n",
       "2   3  Voluntary Early Retirement (VER)    05/2012            2011   \n",
       "3   4         Resignation-Other reasons    05/2012            2005   \n",
       "4   5                    Age Retirement    05/2012            1970   \n",
       "\n",
       "  Role Start Date                                      Position  \\\n",
       "0            2004                                Public Servant   \n",
       "1      Not Stated                                Public Servant   \n",
       "2            2011                               Schools Officer   \n",
       "3            2006                                       Teacher   \n",
       "4            1989  Head of Curriculum/Head of Special Education   \n",
       "\n",
       "  Classification              Region                      Business Unit  \\\n",
       "0        A01-A04      Central Office  Corporate Strategy and Peformance   \n",
       "1        AO5-AO7      Central Office  Corporate Strategy and Peformance   \n",
       "2            NaN      Central Office               Education Queensland   \n",
       "3        Primary  Central Queensland                                NaN   \n",
       "4            NaN          South East                                NaN   \n",
       "\n",
       "     Employment Status  Career move to public sector  \\\n",
       "0  Permanent Full-time                          True   \n",
       "1  Permanent Full-time                         False   \n",
       "2  Permanent Full-time                         False   \n",
       "3  Permanent Full-time                         False   \n",
       "4  Permanent Full-time                         False   \n",
       "\n",
       "   Career move to private sector  Interpersonal conflicts  \\\n",
       "0                          False                    False   \n",
       "1                          False                    False   \n",
       "2                          False                    False   \n",
       "3                           True                    False   \n",
       "4                          False                    False   \n",
       "\n",
       "   Job dissatisfaction  Dissatisfaction with the department  \\\n",
       "0                 True                                False   \n",
       "1                False                                False   \n",
       "2                False                                False   \n",
       "3                False                                False   \n",
       "4                False                                False   \n",
       "\n",
       "   Physical work environment  Lack of recognition  Lack of job security  \\\n",
       "0                      False                 True                 False   \n",
       "1                      False                False                 False   \n",
       "2                      False                False                 False   \n",
       "3                      False                False                 False   \n",
       "4                      False                False                 False   \n",
       "\n",
       "   Work location  Employment conditions  Maternity/family  Relocation  \\\n",
       "0          False                  False             False       False   \n",
       "1          False                  False             False       False   \n",
       "2          False                  False             False       False   \n",
       "3          False                  False             False       False   \n",
       "4          False                  False             False       False   \n",
       "\n",
       "   Study/Travel  Ill Health  Traumatic incident  Work life balance  Workload  \\\n",
       "0         False       False               False              False     False   \n",
       "1         False       False               False              False     False   \n",
       "2         False       False               False              False     False   \n",
       "3         False       False               False              False     False   \n",
       "4         False       False               False               True     False   \n",
       "\n",
       "   None of the above Professional Development Opportunities for promotion  \\\n",
       "0               True                        A                           A   \n",
       "1              False                        A                           A   \n",
       "2               True                        N                           N   \n",
       "3              False                        A                           N   \n",
       "4              False                        A                           A   \n",
       "\n",
       "  Staff morale Workplace issue Physical environment Worklife balance  \\\n",
       "0            N               N                    N                A   \n",
       "1            N               N                    N                N   \n",
       "2            N               N                    N                N   \n",
       "3            N               N                    A                A   \n",
       "4            N               N                    D                D   \n",
       "\n",
       "  Stress and pressure support Performance of supervisor Peer support  \\\n",
       "0                           A                         A            A   \n",
       "1                           A                         A            A   \n",
       "2                           N                         N            N   \n",
       "3                           N                         N            A   \n",
       "4                           N                         A            A   \n",
       "\n",
       "  Initiative Skills Coach Career Aspirations Feedback Further PD  \\\n",
       "0          N      N     N                  A        A          A   \n",
       "1          N      N     N                  A        A          A   \n",
       "2          N      N     N                  N        N          N   \n",
       "3          A      A     A                  A        A          A   \n",
       "4          A      A     A                  A       SA         SA   \n",
       "\n",
       "  Communication My say Information Kept informed Wellness programs  \\\n",
       "0             N      A           A             N                 N   \n",
       "1             N      A           A             N                 N   \n",
       "2             A      A           N             N                 N   \n",
       "3             A      A           A             A                 N   \n",
       "4             D      D           A             N                 A   \n",
       "\n",
       "  Health & Safety  Gender          Age Aboriginal Torres Strait South Sea  \\\n",
       "0               N    Male        56-60        NaN           NaN       NaN   \n",
       "1               N    Male        56-60        NaN           NaN       NaN   \n",
       "2               N    Male  61 or older        NaN           NaN       NaN   \n",
       "3               A  Female        36-40        NaN           NaN       NaN   \n",
       "4               M  Female  61 or older        NaN           NaN       NaN   \n",
       "\n",
       "  Disability NESB  \n",
       "0        NaN  Yes  \n",
       "1        NaN  NaN  \n",
       "2        NaN  NaN  \n",
       "3        NaN  NaN  \n",
       "4        NaN  NaN  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Read in the data\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "dete_survey = pd.read_csv('dete_survey.csv')\n",
    "\n",
    "#Quick exploration of the data\n",
    "pd.options.display.max_columns = 150 # to avoid truncated output \n",
    "dete_survey.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 822 entries, 0 to 821\n",
      "Data columns (total 56 columns):\n",
      " #   Column                               Non-Null Count  Dtype \n",
      "---  ------                               --------------  ----- \n",
      " 0   ID                                   822 non-null    int64 \n",
      " 1   SeparationType                       822 non-null    object\n",
      " 2   Cease Date                           822 non-null    object\n",
      " 3   DETE Start Date                      822 non-null    object\n",
      " 4   Role Start Date                      822 non-null    object\n",
      " 5   Position                             817 non-null    object\n",
      " 6   Classification                       455 non-null    object\n",
      " 7   Region                               822 non-null    object\n",
      " 8   Business Unit                        126 non-null    object\n",
      " 9   Employment Status                    817 non-null    object\n",
      " 10  Career move to public sector         822 non-null    bool  \n",
      " 11  Career move to private sector        822 non-null    bool  \n",
      " 12  Interpersonal conflicts              822 non-null    bool  \n",
      " 13  Job dissatisfaction                  822 non-null    bool  \n",
      " 14  Dissatisfaction with the department  822 non-null    bool  \n",
      " 15  Physical work environment            822 non-null    bool  \n",
      " 16  Lack of recognition                  822 non-null    bool  \n",
      " 17  Lack of job security                 822 non-null    bool  \n",
      " 18  Work location                        822 non-null    bool  \n",
      " 19  Employment conditions                822 non-null    bool  \n",
      " 20  Maternity/family                     822 non-null    bool  \n",
      " 21  Relocation                           822 non-null    bool  \n",
      " 22  Study/Travel                         822 non-null    bool  \n",
      " 23  Ill Health                           822 non-null    bool  \n",
      " 24  Traumatic incident                   822 non-null    bool  \n",
      " 25  Work life balance                    822 non-null    bool  \n",
      " 26  Workload                             822 non-null    bool  \n",
      " 27  None of the above                    822 non-null    bool  \n",
      " 28  Professional Development             808 non-null    object\n",
      " 29  Opportunities for promotion          735 non-null    object\n",
      " 30  Staff morale                         816 non-null    object\n",
      " 31  Workplace issue                      788 non-null    object\n",
      " 32  Physical environment                 817 non-null    object\n",
      " 33  Worklife balance                     815 non-null    object\n",
      " 34  Stress and pressure support          810 non-null    object\n",
      " 35  Performance of supervisor            813 non-null    object\n",
      " 36  Peer support                         812 non-null    object\n",
      " 37  Initiative                           813 non-null    object\n",
      " 38  Skills                               811 non-null    object\n",
      " 39  Coach                                767 non-null    object\n",
      " 40  Career Aspirations                   746 non-null    object\n",
      " 41  Feedback                             792 non-null    object\n",
      " 42  Further PD                           768 non-null    object\n",
      " 43  Communication                        814 non-null    object\n",
      " 44  My say                               812 non-null    object\n",
      " 45  Information                          816 non-null    object\n",
      " 46  Kept informed                        813 non-null    object\n",
      " 47  Wellness programs                    766 non-null    object\n",
      " 48  Health & Safety                      793 non-null    object\n",
      " 49  Gender                               798 non-null    object\n",
      " 50  Age                                  811 non-null    object\n",
      " 51  Aboriginal                           16 non-null     object\n",
      " 52  Torres Strait                        3 non-null      object\n",
      " 53  South Sea                            7 non-null      object\n",
      " 54  Disability                           23 non-null     object\n",
      " 55  NESB                                 32 non-null     object\n",
      "dtypes: bool(18), int64(1), object(37)\n",
      "memory usage: 258.6+ KB\n"
     ]
    }
   ],
   "source": [
    "dete_survey.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Record ID</th>\n",
       "      <th>Institute</th>\n",
       "      <th>WorkArea</th>\n",
       "      <th>CESSATION YEAR</th>\n",
       "      <th>Reason for ceasing employment</th>\n",
       "      <th>Contributing Factors. Career Move - Public Sector</th>\n",
       "      <th>Contributing Factors. Career Move - Private Sector</th>\n",
       "      <th>Contributing Factors. Career Move - Self-employment</th>\n",
       "      <th>Contributing Factors. Ill Health</th>\n",
       "      <th>Contributing Factors. Maternity/Family</th>\n",
       "      <th>Contributing Factors. Dissatisfaction</th>\n",
       "      <th>Contributing Factors. Job Dissatisfaction</th>\n",
       "      <th>Contributing Factors. Interpersonal Conflict</th>\n",
       "      <th>Contributing Factors. Study</th>\n",
       "      <th>Contributing Factors. Travel</th>\n",
       "      <th>Contributing Factors. Other</th>\n",
       "      <th>Contributing Factors. NONE</th>\n",
       "      <th>Main Factor. Which of these was the main factor for leaving?</th>\n",
       "      <th>InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction</th>\n",
       "      <th>InstituteViews. Topic:2. I was given access to skills training to help me do my job better</th>\n",
       "      <th>InstituteViews. Topic:3. I was given adequate opportunities for personal development</th>\n",
       "      <th>InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL%</th>\n",
       "      <th>InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had</th>\n",
       "      <th>InstituteViews. Topic:6. The organisation recognised when staff did good work</th>\n",
       "      <th>InstituteViews. Topic:7. Management was generally supportive of me</th>\n",
       "      <th>InstituteViews. Topic:8. Management was generally supportive of my team</th>\n",
       "      <th>InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me</th>\n",
       "      <th>InstituteViews. Topic:10. Staff morale was positive within the Institute</th>\n",
       "      <th>InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly</th>\n",
       "      <th>InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently</th>\n",
       "      <th>InstituteViews. Topic:13. If I had a workplace issue it was dealt with discreetly</th>\n",
       "      <th>WorkUnitViews. Topic:14. I was satisfied with the quality of the management and supervision within my work unit</th>\n",
       "      <th>WorkUnitViews. Topic:15. I worked well with my colleagues</th>\n",
       "      <th>WorkUnitViews. Topic:16. My job was challenging and interesting</th>\n",
       "      <th>WorkUnitViews. Topic:17. I was encouraged to use my initiative in the course of my work</th>\n",
       "      <th>WorkUnitViews. Topic:18. I had sufficient contact with other people in my job</th>\n",
       "      <th>WorkUnitViews. Topic:19. I was given adequate support and co-operation by my peers to enable me to do my job</th>\n",
       "      <th>WorkUnitViews. Topic:20. I was able to use the full range of my skills in my job</th>\n",
       "      <th>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]</th>\n",
       "      <th>WorkUnitViews. Topic:22. I was able to use the full range of my knowledge in my job</th>\n",
       "      <th>WorkUnitViews. Topic:23. My job provided sufficient variety</th>\n",
       "      <th>WorkUnitViews. Topic:24. I was able to cope with the level of stress and pressure in my job</th>\n",
       "      <th>WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction</th>\n",
       "      <th>WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance</th>\n",
       "      <th>WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area</th>\n",
       "      <th>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</th>\n",
       "      <th>WorkUnitViews. Topic:29. There was adequate communication between staff in my unit</th>\n",
       "      <th>WorkUnitViews. Topic:30. Staff morale was positive within my work unit</th>\n",
       "      <th>Induction. Did you undertake Workplace Induction?</th>\n",
       "      <th>InductionInfo. Topic:Did you undertake a Corporate Induction?</th>\n",
       "      <th>InductionInfo. Topic:Did you undertake a Institute Induction?</th>\n",
       "      <th>InductionInfo. Topic: Did you undertake Team Induction?</th>\n",
       "      <th>InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted?</th>\n",
       "      <th>InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted?</th>\n",
       "      <th>InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction?</th>\n",
       "      <th>InductionInfo. Face to Face Topic:Did you undertake a Institute Induction?</th>\n",
       "      <th>InductionInfo. On-line Topic:Did you undertake a Institute Induction?</th>\n",
       "      <th>InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction?</th>\n",
       "      <th>InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category?</th>\n",
       "      <th>InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.]</th>\n",
       "      <th>InductionInfo. Induction Manual Topic: Did you undertake Team Induction?</th>\n",
       "      <th>Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)?</th>\n",
       "      <th>Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination?</th>\n",
       "      <th>Workplace. Topic:Does your workplace promote and practice the principles of employment equity?</th>\n",
       "      <th>Workplace. Topic:Does your workplace value the diversity of its employees?</th>\n",
       "      <th>Workplace. Topic:Would you recommend the Institute as an employer to others?</th>\n",
       "      <th>Gender. What is your Gender?</th>\n",
       "      <th>CurrentAge. Current Age</th>\n",
       "      <th>Employment Type. Employment Type</th>\n",
       "      <th>Classification. Classification</th>\n",
       "      <th>LengthofServiceOverall. Overall Length of Service at Institute (in years)</th>\n",
       "      <th>LengthofServiceCurrent. Length of Service at current workplace (in years)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6.341330e+17</td>\n",
       "      <td>Southern Queensland Institute of TAFE</td>\n",
       "      <td>Non-Delivery (corporate)</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>Contract Expired</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Neutral</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Neutral</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Face to Face</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Face to Face</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Face to Face</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Female</td>\n",
       "      <td>26  30</td>\n",
       "      <td>Temporary Full-time</td>\n",
       "      <td>Administration (AO)</td>\n",
       "      <td>1-2</td>\n",
       "      <td>1-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6.341337e+17</td>\n",
       "      <td>Mount Isa Institute of TAFE</td>\n",
       "      <td>Non-Delivery (corporate)</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>Retirement</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Travel</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Disagree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>No</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6.341388e+17</td>\n",
       "      <td>Mount Isa Institute of TAFE</td>\n",
       "      <td>Delivery (teaching)</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>Retirement</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Neutral</td>\n",
       "      <td>Neutral</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>No</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>6.341399e+17</td>\n",
       "      <td>Mount Isa Institute of TAFE</td>\n",
       "      <td>Non-Delivery (corporate)</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>Resignation</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Travel</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Yes</td>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6.341466e+17</td>\n",
       "      <td>Southern Queensland Institute of TAFE</td>\n",
       "      <td>Delivery (teaching)</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>Resignation</td>\n",
       "      <td>-</td>\n",
       "      <td>Career Move - Private Sector</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Strongly Agree</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Induction Manual</td>\n",
       "      <td>Face to Face</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Face to Face</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Male</td>\n",
       "      <td>41  45</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>Teacher (including LVT)</td>\n",
       "      <td>3-4</td>\n",
       "      <td>3-4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Record ID                              Institute  \\\n",
       "0  6.341330e+17  Southern Queensland Institute of TAFE   \n",
       "1  6.341337e+17            Mount Isa Institute of TAFE   \n",
       "2  6.341388e+17            Mount Isa Institute of TAFE   \n",
       "3  6.341399e+17            Mount Isa Institute of TAFE   \n",
       "4  6.341466e+17  Southern Queensland Institute of TAFE   \n",
       "\n",
       "                   WorkArea  CESSATION YEAR Reason for ceasing employment  \\\n",
       "0  Non-Delivery (corporate)          2010.0              Contract Expired   \n",
       "1  Non-Delivery (corporate)          2010.0                    Retirement   \n",
       "2       Delivery (teaching)          2010.0                    Retirement   \n",
       "3  Non-Delivery (corporate)          2010.0                   Resignation   \n",
       "4       Delivery (teaching)          2010.0                   Resignation   \n",
       "\n",
       "  Contributing Factors. Career Move - Public Sector   \\\n",
       "0                                                NaN   \n",
       "1                                                  -   \n",
       "2                                                  -   \n",
       "3                                                  -   \n",
       "4                                                  -   \n",
       "\n",
       "  Contributing Factors. Career Move - Private Sector   \\\n",
       "0                                                NaN    \n",
       "1                                                  -    \n",
       "2                                                  -    \n",
       "3                                                  -    \n",
       "4                       Career Move - Private Sector    \n",
       "\n",
       "  Contributing Factors. Career Move - Self-employment  \\\n",
       "0                                                NaN    \n",
       "1                                                  -    \n",
       "2                                                  -    \n",
       "3                                                  -    \n",
       "4                                                  -    \n",
       "\n",
       "  Contributing Factors. Ill Health Contributing Factors. Maternity/Family  \\\n",
       "0                              NaN                                    NaN   \n",
       "1                                -                                      -   \n",
       "2                                -                                      -   \n",
       "3                                -                                      -   \n",
       "4                                -                                      -   \n",
       "\n",
       "  Contributing Factors. Dissatisfaction  \\\n",
       "0                                   NaN   \n",
       "1                                     -   \n",
       "2                                     -   \n",
       "3                                     -   \n",
       "4                                     -   \n",
       "\n",
       "  Contributing Factors. Job Dissatisfaction  \\\n",
       "0                                       NaN   \n",
       "1                                         -   \n",
       "2                                         -   \n",
       "3                                         -   \n",
       "4                                         -   \n",
       "\n",
       "  Contributing Factors. Interpersonal Conflict Contributing Factors. Study  \\\n",
       "0                                          NaN                         NaN   \n",
       "1                                            -                           -   \n",
       "2                                            -                           -   \n",
       "3                                            -                           -   \n",
       "4                                            -                           -   \n",
       "\n",
       "  Contributing Factors. Travel Contributing Factors. Other  \\\n",
       "0                          NaN                         NaN   \n",
       "1                       Travel                           -   \n",
       "2                            -                           -   \n",
       "3                       Travel                           -   \n",
       "4                            -                           -   \n",
       "\n",
       "  Contributing Factors. NONE  \\\n",
       "0                        NaN   \n",
       "1                          -   \n",
       "2                       NONE   \n",
       "3                          -   \n",
       "4                          -   \n",
       "\n",
       "  Main Factor. Which of these was the main factor for leaving?  \\\n",
       "0                                                NaN             \n",
       "1                                                NaN             \n",
       "2                                                NaN             \n",
       "3                                                NaN             \n",
       "4                                                NaN             \n",
       "\n",
       "  InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction  \\\n",
       "0                                              Agree                                       \n",
       "1                                              Agree                                       \n",
       "2                                              Agree                                       \n",
       "3                                              Agree                                       \n",
       "4                                              Agree                                       \n",
       "\n",
       "  InstituteViews. Topic:2. I was given access to skills training to help me do my job better  \\\n",
       "0                                              Agree                                           \n",
       "1                                              Agree                                           \n",
       "2                                              Agree                                           \n",
       "3                                              Agree                                           \n",
       "4                                              Agree                                           \n",
       "\n",
       "  InstituteViews. Topic:3. I was given adequate opportunities for personal development  \\\n",
       "0                                              Agree                                     \n",
       "1                                              Agree                                     \n",
       "2                                              Agree                                     \n",
       "3                                              Agree                                     \n",
       "4                                     Strongly Agree                                     \n",
       "\n",
       "  InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL%  \\\n",
       "0                                            Neutral                                                    \n",
       "1                                              Agree                                                    \n",
       "2                                              Agree                                                    \n",
       "3                                              Agree                                                    \n",
       "4                                              Agree                                                    \n",
       "\n",
       "  InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had  \\\n",
       "0                                              Agree                                                \n",
       "1                                              Agree                                                \n",
       "2                                              Agree                                                \n",
       "3                                              Agree                                                \n",
       "4                                     Strongly Agree                                                \n",
       "\n",
       "  InstituteViews. Topic:6. The organisation recognised when staff did good work  \\\n",
       "0                                              Agree                              \n",
       "1                                     Strongly Agree                              \n",
       "2                                              Agree                              \n",
       "3                                              Agree                              \n",
       "4                                     Strongly Agree                              \n",
       "\n",
       "  InstituteViews. Topic:7. Management was generally supportive of me  \\\n",
       "0                                              Agree                   \n",
       "1                                     Strongly Agree                   \n",
       "2                                     Strongly Agree                   \n",
       "3                                              Agree                   \n",
       "4                                     Strongly Agree                   \n",
       "\n",
       "  InstituteViews. Topic:8. Management was generally supportive of my team  \\\n",
       "0                                              Agree                        \n",
       "1                                              Agree                        \n",
       "2                                              Agree                        \n",
       "3                                              Agree                        \n",
       "4                                     Strongly Agree                        \n",
       "\n",
       "  InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me  \\\n",
       "0                                              Agree                                                      \n",
       "1                                     Strongly Agree                                                      \n",
       "2                                              Agree                                                      \n",
       "3                                              Agree                                                      \n",
       "4                                              Agree                                                      \n",
       "\n",
       "  InstituteViews. Topic:10. Staff morale was positive within the Institute  \\\n",
       "0                                              Agree                         \n",
       "1                                              Agree                         \n",
       "2                                              Agree                         \n",
       "3                                              Agree                         \n",
       "4                                     Strongly Agree                         \n",
       "\n",
       "  InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly  \\\n",
       "0                                              Agree                               \n",
       "1                                              Agree                               \n",
       "2                                              Agree                               \n",
       "3                                              Agree                               \n",
       "4                                     Strongly Agree                               \n",
       "\n",
       "  InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently  \\\n",
       "0                                              Agree                                   \n",
       "1                                              Agree                                   \n",
       "2                                            Neutral                                   \n",
       "3                                              Agree                                   \n",
       "4                                              Agree                                   \n",
       "\n",
       "  InstituteViews. Topic:13. If I had a workplace issue it was dealt with discreetly  \\\n",
       "0                                              Agree                                  \n",
       "1                                           Disagree                                  \n",
       "2                                            Neutral                                  \n",
       "3                                              Agree                                  \n",
       "4                                     Strongly Agree                                  \n",
       "\n",
       "  WorkUnitViews. Topic:14. I was satisfied with the quality of the management and supervision within my work unit  \\\n",
       "0                                              Agree                                                                \n",
       "1                                     Strongly Agree                                                                \n",
       "2                                     Strongly Agree                                                                \n",
       "3                                     Strongly Agree                                                                \n",
       "4                                     Strongly Agree                                                                \n",
       "\n",
       "  WorkUnitViews. Topic:15. I worked well with my colleagues  \\\n",
       "0                                              Agree          \n",
       "1                                     Strongly Agree          \n",
       "2                                     Strongly Agree          \n",
       "3                                     Strongly Agree          \n",
       "4                                     Strongly Agree          \n",
       "\n",
       "  WorkUnitViews. Topic:16. My job was challenging and interesting  \\\n",
       "0                                              Agree                \n",
       "1                                     Strongly Agree                \n",
       "2                                              Agree                \n",
       "3                                     Strongly Agree                \n",
       "4                                     Strongly Agree                \n",
       "\n",
       "  WorkUnitViews. Topic:17. I was encouraged to use my initiative in the course of my work  \\\n",
       "0                                     Strongly Agree                                        \n",
       "1                                              Agree                                        \n",
       "2                                              Agree                                        \n",
       "3                                     Strongly Agree                                        \n",
       "4                                     Strongly Agree                                        \n",
       "\n",
       "  WorkUnitViews. Topic:18. I had sufficient contact with other people in my job  \\\n",
       "0                                              Agree                              \n",
       "1                                              Agree                              \n",
       "2                                              Agree                              \n",
       "3                                     Strongly Agree                              \n",
       "4                                     Strongly Agree                              \n",
       "\n",
       "  WorkUnitViews. Topic:19. I was given adequate support and co-operation by my peers to enable me to do my job  \\\n",
       "0                                              Agree                                                             \n",
       "1                                              Agree                                                             \n",
       "2                                              Agree                                                             \n",
       "3                                     Strongly Agree                                                             \n",
       "4                                     Strongly Agree                                                             \n",
       "\n",
       "  WorkUnitViews. Topic:20. I was able to use the full range of my skills in my job  \\\n",
       "0                                              Agree                                 \n",
       "1                                     Strongly Agree                                 \n",
       "2                                              Agree                                 \n",
       "3                                     Strongly Agree                                 \n",
       "4                                     Strongly Agree                                 \n",
       "\n",
       "  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]  \\\n",
       "0                                              Agree                                                                                                              \n",
       "1                                              Agree                                                                                                              \n",
       "2                                              Agree                                                                                                              \n",
       "3                                     Strongly Agree                                                                                                              \n",
       "4                                     Strongly Agree                                                                                                              \n",
       "\n",
       "  WorkUnitViews. Topic:22. I was able to use the full range of my knowledge in my job  \\\n",
       "0                                              Agree                                    \n",
       "1                                              Agree                                    \n",
       "2                                              Agree                                    \n",
       "3                                     Strongly Agree                                    \n",
       "4                                     Strongly Agree                                    \n",
       "\n",
       "  WorkUnitViews. Topic:23. My job provided sufficient variety  \\\n",
       "0                                              Agree            \n",
       "1                                              Agree            \n",
       "2                                              Agree            \n",
       "3                                     Strongly Agree            \n",
       "4                                     Strongly Agree            \n",
       "\n",
       "  WorkUnitViews. Topic:24. I was able to cope with the level of stress and pressure in my job  \\\n",
       "0                                              Agree                                            \n",
       "1                                     Strongly Agree                                            \n",
       "2                                              Agree                                            \n",
       "3                                     Strongly Agree                                            \n",
       "4                                     Strongly Agree                                            \n",
       "\n",
       "  WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction  \\\n",
       "0                                              Agree                                                        \n",
       "1                                              Agree                                                        \n",
       "2                                              Agree                                                        \n",
       "3                                     Strongly Agree                                                        \n",
       "4                                     Strongly Agree                                                        \n",
       "\n",
       "  WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance  \\\n",
       "0                                              Agree                                                            \n",
       "1                                     Strongly Agree                                                            \n",
       "2                                              Agree                                                            \n",
       "3                                     Strongly Agree                                                            \n",
       "4                                     Strongly Agree                                                            \n",
       "\n",
       "  WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area  \\\n",
       "0                                              Agree                                                                                         \n",
       "1                                     Strongly Agree                                                                                         \n",
       "2                                              Agree                                                                                         \n",
       "3                                     Strongly Agree                                                                                         \n",
       "4                                     Strongly Agree                                                                                         \n",
       "\n",
       "  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  \\\n",
       "0                                            Neutral                                                                                                              \n",
       "1                                              Agree                                                                                                              \n",
       "2                                              Agree                                                                                                              \n",
       "3                                     Strongly Agree                                                                                                              \n",
       "4                                     Strongly Agree                                                                                                              \n",
       "\n",
       "  WorkUnitViews. Topic:29. There was adequate communication between staff in my unit  \\\n",
       "0                                              Agree                                   \n",
       "1                                              Agree                                   \n",
       "2                                              Agree                                   \n",
       "3                                     Strongly Agree                                   \n",
       "4                                     Strongly Agree                                   \n",
       "\n",
       "  WorkUnitViews. Topic:30. Staff morale was positive within my work unit  \\\n",
       "0                                              Agree                       \n",
       "1                                     Strongly Agree                       \n",
       "2                                              Agree                       \n",
       "3                                     Strongly Agree                       \n",
       "4                                     Strongly Agree                       \n",
       "\n",
       "  Induction. Did you undertake Workplace Induction?  \\\n",
       "0                                               Yes   \n",
       "1                                                No   \n",
       "2                                                No   \n",
       "3                                               Yes   \n",
       "4                                               Yes   \n",
       "\n",
       "  InductionInfo. Topic:Did you undertake a Corporate Induction?  \\\n",
       "0                                                Yes              \n",
       "1                                                NaN              \n",
       "2                                                NaN              \n",
       "3                                                 No              \n",
       "4                                                Yes              \n",
       "\n",
       "  InductionInfo. Topic:Did you undertake a Institute Induction?  \\\n",
       "0                                                Yes              \n",
       "1                                                NaN              \n",
       "2                                                NaN              \n",
       "3                                                Yes              \n",
       "4                                                Yes              \n",
       "\n",
       "  InductionInfo. Topic: Did you undertake Team Induction?  \\\n",
       "0                                                Yes        \n",
       "1                                                NaN        \n",
       "2                                                NaN        \n",
       "3                                                Yes        \n",
       "4                                                Yes        \n",
       "\n",
       "  InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted?  \\\n",
       "0                                       Face to Face                                                          \n",
       "1                                                NaN                                                          \n",
       "2                                                NaN                                                          \n",
       "3                                                  -                                                          \n",
       "4                                                  -                                                          \n",
       "\n",
       "  InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted?  \\\n",
       "0                                                  -                                                     \n",
       "1                                                NaN                                                     \n",
       "2                                                NaN                                                     \n",
       "3                                                  -                                                     \n",
       "4                                                  -                                                     \n",
       "\n",
       "  InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction?  \\\n",
       "0                                                  -                               \n",
       "1                                                NaN                               \n",
       "2                                                NaN                               \n",
       "3                                                  -                               \n",
       "4                                   Induction Manual                               \n",
       "\n",
       "  InductionInfo. Face to Face Topic:Did you undertake a Institute Induction?  \\\n",
       "0                                       Face to Face                           \n",
       "1                                                NaN                           \n",
       "2                                                NaN                           \n",
       "3                                                NaN                           \n",
       "4                                       Face to Face                           \n",
       "\n",
       "  InductionInfo. On-line Topic:Did you undertake a Institute Induction?  \\\n",
       "0                                                  -                      \n",
       "1                                                NaN                      \n",
       "2                                                NaN                      \n",
       "3                                                  -                      \n",
       "4                                                  -                      \n",
       "\n",
       "  InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction?  \\\n",
       "0                                                  -                               \n",
       "1                                                NaN                               \n",
       "2                                                NaN                               \n",
       "3                                                  -                               \n",
       "4                                                  -                               \n",
       "\n",
       "  InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category?  \\\n",
       "0                                       Face to Face                               \n",
       "1                                                NaN                               \n",
       "2                                                NaN                               \n",
       "3                                                  -                               \n",
       "4                                       Face to Face                               \n",
       "\n",
       "  InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.]  \\\n",
       "0                                                  -                                                                \n",
       "1                                                NaN                                                                \n",
       "2                                                NaN                                                                \n",
       "3                                                  -                                                                \n",
       "4                                                  -                                                                \n",
       "\n",
       "  InductionInfo. Induction Manual Topic: Did you undertake Team Induction?  \\\n",
       "0                                                  -                         \n",
       "1                                                NaN                         \n",
       "2                                                NaN                         \n",
       "3                                                  -                         \n",
       "4                                                  -                         \n",
       "\n",
       "  Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)?  \\\n",
       "0                                                Yes                                                          \n",
       "1                                                Yes                                                          \n",
       "2                                                Yes                                                          \n",
       "3                                                Yes                                                          \n",
       "4                                                Yes                                                          \n",
       "\n",
       "  Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination?  \\\n",
       "0                                                Yes                                                            \n",
       "1                                                Yes                                                            \n",
       "2                                                Yes                                                            \n",
       "3                                                Yes                                                            \n",
       "4                                                Yes                                                            \n",
       "\n",
       "  Workplace. Topic:Does your workplace promote and practice the principles of employment equity?  \\\n",
       "0                                                Yes                                               \n",
       "1                                                Yes                                               \n",
       "2                                                Yes                                               \n",
       "3                                                Yes                                               \n",
       "4                                                Yes                                               \n",
       "\n",
       "  Workplace. Topic:Does your workplace value the diversity of its employees?  \\\n",
       "0                                                Yes                           \n",
       "1                                                Yes                           \n",
       "2                                                Yes                           \n",
       "3                                                Yes                           \n",
       "4                                                Yes                           \n",
       "\n",
       "  Workplace. Topic:Would you recommend the Institute as an employer to others?  \\\n",
       "0                                                Yes                             \n",
       "1                                                Yes                             \n",
       "2                                                Yes                             \n",
       "3                                                Yes                             \n",
       "4                                                Yes                             \n",
       "\n",
       "  Gender. What is your Gender? CurrentAge. Current Age  \\\n",
       "0                       Female                  26  30   \n",
       "1                          NaN                     NaN   \n",
       "2                          NaN                     NaN   \n",
       "3                          NaN                     NaN   \n",
       "4                         Male                  41  45   \n",
       "\n",
       "  Employment Type. Employment Type Classification. Classification  \\\n",
       "0              Temporary Full-time            Administration (AO)   \n",
       "1                              NaN                            NaN   \n",
       "2                              NaN                            NaN   \n",
       "3                              NaN                            NaN   \n",
       "4              Permanent Full-time        Teacher (including LVT)   \n",
       "\n",
       "  LengthofServiceOverall. Overall Length of Service at Institute (in years)  \\\n",
       "0                                                1-2                          \n",
       "1                                                NaN                          \n",
       "2                                                NaN                          \n",
       "3                                                NaN                          \n",
       "4                                                3-4                          \n",
       "\n",
       "  LengthofServiceCurrent. Length of Service at current workplace (in years)  \n",
       "0                                                1-2                         \n",
       "1                                                NaN                         \n",
       "2                                                NaN                         \n",
       "3                                                NaN                         \n",
       "4                                                3-4                         "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Read in the data\n",
    "tafe_survey = pd.read_csv(\"tafe_survey.csv\")\n",
    "\n",
    "#Quick exploration of the data\n",
    "tafe_survey.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 702 entries, 0 to 701\n",
      "Data columns (total 72 columns):\n",
      " #   Column                                                                                                                                                         Non-Null Count  Dtype  \n",
      "---  ------                                                                                                                                                         --------------  -----  \n",
      " 0   Record ID                                                                                                                                                      702 non-null    float64\n",
      " 1   Institute                                                                                                                                                      702 non-null    object \n",
      " 2   WorkArea                                                                                                                                                       702 non-null    object \n",
      " 3   CESSATION YEAR                                                                                                                                                 695 non-null    float64\n",
      " 4   Reason for ceasing employment                                                                                                                                  701 non-null    object \n",
      " 5   Contributing Factors. Career Move - Public Sector                                                                                                              437 non-null    object \n",
      " 6   Contributing Factors. Career Move - Private Sector                                                                                                             437 non-null    object \n",
      " 7   Contributing Factors. Career Move - Self-employment                                                                                                            437 non-null    object \n",
      " 8   Contributing Factors. Ill Health                                                                                                                               437 non-null    object \n",
      " 9   Contributing Factors. Maternity/Family                                                                                                                         437 non-null    object \n",
      " 10  Contributing Factors. Dissatisfaction                                                                                                                          437 non-null    object \n",
      " 11  Contributing Factors. Job Dissatisfaction                                                                                                                      437 non-null    object \n",
      " 12  Contributing Factors. Interpersonal Conflict                                                                                                                   437 non-null    object \n",
      " 13  Contributing Factors. Study                                                                                                                                    437 non-null    object \n",
      " 14  Contributing Factors. Travel                                                                                                                                   437 non-null    object \n",
      " 15  Contributing Factors. Other                                                                                                                                    437 non-null    object \n",
      " 16  Contributing Factors. NONE                                                                                                                                     437 non-null    object \n",
      " 17  Main Factor. Which of these was the main factor for leaving?                                                                                                   113 non-null    object \n",
      " 18  InstituteViews. Topic:1. I feel the senior leadership had a clear vision and direction                                                                         608 non-null    object \n",
      " 19  InstituteViews. Topic:2. I was given access to skills training to help me do my job better                                                                     613 non-null    object \n",
      " 20  InstituteViews. Topic:3. I was given adequate opportunities for personal development                                                                           610 non-null    object \n",
      " 21  InstituteViews. Topic:4. I was given adequate opportunities for promotion within %Institute]Q25LBL%                                                            608 non-null    object \n",
      " 22  InstituteViews. Topic:5. I felt the salary for the job was right for the responsibilities I had                                                                615 non-null    object \n",
      " 23  InstituteViews. Topic:6. The organisation recognised when staff did good work                                                                                  607 non-null    object \n",
      " 24  InstituteViews. Topic:7. Management was generally supportive of me                                                                                             614 non-null    object \n",
      " 25  InstituteViews. Topic:8. Management was generally supportive of my team                                                                                        608 non-null    object \n",
      " 26  InstituteViews. Topic:9. I was kept informed of the changes in the organisation which would affect me                                                          610 non-null    object \n",
      " 27  InstituteViews. Topic:10. Staff morale was positive within the Institute                                                                                       602 non-null    object \n",
      " 28  InstituteViews. Topic:11. If I had a workplace issue it was dealt with quickly                                                                                 601 non-null    object \n",
      " 29  InstituteViews. Topic:12. If I had a workplace issue it was dealt with efficiently                                                                             597 non-null    object \n",
      " 30  InstituteViews. Topic:13. If I had a workplace issue it was dealt with discreetly                                                                              601 non-null    object \n",
      " 31  WorkUnitViews. Topic:14. I was satisfied with the quality of the management and supervision within my work unit                                                609 non-null    object \n",
      " 32  WorkUnitViews. Topic:15. I worked well with my colleagues                                                                                                      605 non-null    object \n",
      " 33  WorkUnitViews. Topic:16. My job was challenging and interesting                                                                                                607 non-null    object \n",
      " 34  WorkUnitViews. Topic:17. I was encouraged to use my initiative in the course of my work                                                                        610 non-null    object \n",
      " 35  WorkUnitViews. Topic:18. I had sufficient contact with other people in my job                                                                                  613 non-null    object \n",
      " 36  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 \n",
      " 37  WorkUnitViews. Topic:20. I was able to use the full range of my skills in my job                                                                               609 non-null    object \n",
      " 38  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 \n",
      " 39  WorkUnitViews. Topic:22. I was able to use the full range of my knowledge in my job                                                                            608 non-null    object \n",
      " 40  WorkUnitViews. Topic:23. My job provided sufficient variety                                                                                                    611 non-null    object \n",
      " 41  WorkUnitViews. Topic:24. I was able to cope with the level of stress and pressure in my job                                                                    610 non-null    object \n",
      " 42  WorkUnitViews. Topic:25. My job allowed me to balance the demands of work and family to my satisfaction                                                        611 non-null    object \n",
      " 43  WorkUnitViews. Topic:26. My supervisor gave me adequate personal recognition and feedback on my performance                                                    606 non-null    object \n",
      " 44  WorkUnitViews. Topic:27. My working environment was satisfactory e.g. sufficient space, good lighting, suitable seating and working area                       610 non-null    object \n",
      " 45  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 \n",
      " 46  WorkUnitViews. Topic:29. There was adequate communication between staff in my unit                                                                             603 non-null    object \n",
      " 47  WorkUnitViews. Topic:30. Staff morale was positive within my work unit                                                                                         606 non-null    object \n",
      " 48  Induction. Did you undertake Workplace Induction?                                                                                                              619 non-null    object \n",
      " 49  InductionInfo. Topic:Did you undertake a Corporate Induction?                                                                                                  432 non-null    object \n",
      " 50  InductionInfo. Topic:Did you undertake a Institute Induction?                                                                                                  483 non-null    object \n",
      " 51  InductionInfo. Topic: Did you undertake Team Induction?                                                                                                        440 non-null    object \n",
      " 52  InductionInfo. Face to Face Topic:Did you undertake a Corporate Induction; Category:How it was conducted?                                                      555 non-null    object \n",
      " 53  InductionInfo. On-line Topic:Did you undertake a Corporate Induction; Category:How it was conducted?                                                           555 non-null    object \n",
      " 54  InductionInfo. Induction Manual Topic:Did you undertake a Corporate Induction?                                                                                 555 non-null    object \n",
      " 55  InductionInfo. Face to Face Topic:Did you undertake a Institute Induction?                                                                                     530 non-null    object \n",
      " 56  InductionInfo. On-line Topic:Did you undertake a Institute Induction?                                                                                          555 non-null    object \n",
      " 57  InductionInfo. Induction Manual Topic:Did you undertake a Institute Induction?                                                                                 553 non-null    object \n",
      " 58  InductionInfo. Face to Face Topic: Did you undertake Team Induction; Category?                                                                                 555 non-null    object \n",
      " 59  InductionInfo. On-line Topic: Did you undertake Team Induction?process you undertook and how it was conducted.]                                                555 non-null    object \n",
      " 60  InductionInfo. Induction Manual Topic: Did you undertake Team Induction?                                                                                       555 non-null    object \n",
      " 61  Workplace. Topic:Did you and your Manager develop a Performance and Professional Development Plan (PPDP)?                                                      608 non-null    object \n",
      " 62  Workplace. Topic:Does your workplace promote a work culture free from all forms of unlawful discrimination?                                                    594 non-null    object \n",
      " 63  Workplace. Topic:Does your workplace promote and practice the principles of employment equity?                                                                 587 non-null    object \n",
      " 64  Workplace. Topic:Does your workplace value the diversity of its employees?                                                                                     586 non-null    object \n",
      " 65  Workplace. Topic:Would you recommend the Institute as an employer to others?                                                                                   581 non-null    object \n",
      " 66  Gender. What is your Gender?                                                                                                                                   596 non-null    object \n",
      " 67  CurrentAge. Current Age                                                                                                                                        596 non-null    object \n",
      " 68  Employment Type. Employment Type                                                                                                                               596 non-null    object \n",
      " 69  Classification. Classification                                                                                                                                 596 non-null    object \n",
      " 70  LengthofServiceOverall. Overall Length of Service at Institute (in years)                                                                                      596 non-null    object \n",
      " 71  LengthofServiceCurrent. Length of Service at current workplace (in years)                                                                                      596 non-null    object \n",
      "dtypes: float64(2), object(70)\n",
      "memory usage: 395.0+ KB\n"
     ]
    }
   ],
   "source": [
    "tafe_survey.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can make the following observations based on the work above:\n",
    "  - The `dete_survey` dataframe contains `'Not Stated'` values that indicate values are missing, but they aren't represented as `NaN`.\n",
    "  - Both the `dete_survey` and `tafe_survey` contain many columns that we don't need to complete our analysis.\n",
    "  - Each dataframe contains many of the same columns, but the column names are different.\n",
    "  - There are multiple columns/answers that indicate an employee resigned because they were dissatisfied."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Identify Missing Values and Drop Unneccessary Columns\n",
    "\n",
    "First, we'll correct the `Not Stated` values and drop some of the columns we don't need for our analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>SeparationType</th>\n",
       "      <th>Cease Date</th>\n",
       "      <th>DETE Start Date</th>\n",
       "      <th>Role Start Date</th>\n",
       "      <th>Position</th>\n",
       "      <th>Classification</th>\n",
       "      <th>Region</th>\n",
       "      <th>Business Unit</th>\n",
       "      <th>Employment Status</th>\n",
       "      <th>Career move to public sector</th>\n",
       "      <th>Career move to private sector</th>\n",
       "      <th>Interpersonal conflicts</th>\n",
       "      <th>Job dissatisfaction</th>\n",
       "      <th>Dissatisfaction with the department</th>\n",
       "      <th>Physical work environment</th>\n",
       "      <th>Lack of recognition</th>\n",
       "      <th>Lack of job security</th>\n",
       "      <th>Work location</th>\n",
       "      <th>Employment conditions</th>\n",
       "      <th>Maternity/family</th>\n",
       "      <th>Relocation</th>\n",
       "      <th>Study/Travel</th>\n",
       "      <th>Ill Health</th>\n",
       "      <th>Traumatic incident</th>\n",
       "      <th>Work life balance</th>\n",
       "      <th>Workload</th>\n",
       "      <th>None of the above</th>\n",
       "      <th>Professional Development</th>\n",
       "      <th>Opportunities for promotion</th>\n",
       "      <th>Staff morale</th>\n",
       "      <th>Workplace issue</th>\n",
       "      <th>Physical environment</th>\n",
       "      <th>Worklife balance</th>\n",
       "      <th>Stress and pressure support</th>\n",
       "      <th>Performance of supervisor</th>\n",
       "      <th>Peer support</th>\n",
       "      <th>Initiative</th>\n",
       "      <th>Skills</th>\n",
       "      <th>Coach</th>\n",
       "      <th>Career Aspirations</th>\n",
       "      <th>Feedback</th>\n",
       "      <th>Further PD</th>\n",
       "      <th>Communication</th>\n",
       "      <th>My say</th>\n",
       "      <th>Information</th>\n",
       "      <th>Kept informed</th>\n",
       "      <th>Wellness programs</th>\n",
       "      <th>Health &amp; Safety</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Aboriginal</th>\n",
       "      <th>Torres Strait</th>\n",
       "      <th>South Sea</th>\n",
       "      <th>Disability</th>\n",
       "      <th>NESB</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Ill Health Retirement</td>\n",
       "      <td>08/2012</td>\n",
       "      <td>1984.0</td>\n",
       "      <td>2004.0</td>\n",
       "      <td>Public Servant</td>\n",
       "      <td>A01-A04</td>\n",
       "      <td>Central Office</td>\n",
       "      <td>Corporate Strategy and Peformance</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>56-60</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Voluntary Early Retirement (VER)</td>\n",
       "      <td>08/2012</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Public Servant</td>\n",
       "      <td>AO5-AO7</td>\n",
       "      <td>Central Office</td>\n",
       "      <td>Corporate Strategy and Peformance</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>56-60</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Voluntary Early Retirement (VER)</td>\n",
       "      <td>05/2012</td>\n",
       "      <td>2011.0</td>\n",
       "      <td>2011.0</td>\n",
       "      <td>Schools Officer</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Central Office</td>\n",
       "      <td>Education Queensland</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>61 or older</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Resignation-Other reasons</td>\n",
       "      <td>05/2012</td>\n",
       "      <td>2005.0</td>\n",
       "      <td>2006.0</td>\n",
       "      <td>Teacher</td>\n",
       "      <td>Primary</td>\n",
       "      <td>Central Queensland</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>Female</td>\n",
       "      <td>36-40</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Age Retirement</td>\n",
       "      <td>05/2012</td>\n",
       "      <td>1970.0</td>\n",
       "      <td>1989.0</td>\n",
       "      <td>Head of Curriculum/Head of Special Education</td>\n",
       "      <td>NaN</td>\n",
       "      <td>South East</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Permanent Full-time</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>N</td>\n",
       "      <td>D</td>\n",
       "      <td>D</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>SA</td>\n",
       "      <td>SA</td>\n",
       "      <td>D</td>\n",
       "      <td>D</td>\n",
       "      <td>A</td>\n",
       "      <td>N</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "      <td>Female</td>\n",
       "      <td>61 or older</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ID                    SeparationType Cease Date  DETE Start Date  \\\n",
       "0   1             Ill Health Retirement    08/2012           1984.0   \n",
       "1   2  Voluntary Early Retirement (VER)    08/2012              NaN   \n",
       "2   3  Voluntary Early Retirement (VER)    05/2012           2011.0   \n",
       "3   4         Resignation-Other reasons    05/2012           2005.0   \n",
       "4   5                    Age Retirement    05/2012           1970.0   \n",
       "\n",
       "   Role Start Date                                      Position  \\\n",
       "0           2004.0                                Public Servant   \n",
       "1              NaN                                Public Servant   \n",
       "2           2011.0                               Schools Officer   \n",
       "3           2006.0                                       Teacher   \n",
       "4           1989.0  Head of Curriculum/Head of Special Education   \n",
       "\n",
       "  Classification              Region                      Business Unit  \\\n",
       "0        A01-A04      Central Office  Corporate Strategy and Peformance   \n",
       "1        AO5-AO7      Central Office  Corporate Strategy and Peformance   \n",
       "2            NaN      Central Office               Education Queensland   \n",
       "3        Primary  Central Queensland                                NaN   \n",
       "4            NaN          South East                                NaN   \n",
       "\n",
       "     Employment Status  Career move to public sector  \\\n",
       "0  Permanent Full-time                          True   \n",
       "1  Permanent Full-time                         False   \n",
       "2  Permanent Full-time                         False   \n",
       "3  Permanent Full-time                         False   \n",
       "4  Permanent Full-time                         False   \n",
       "\n",
       "   Career move to private sector  Interpersonal conflicts  \\\n",
       "0                          False                    False   \n",
       "1                          False                    False   \n",
       "2                          False                    False   \n",
       "3                           True                    False   \n",
       "4                          False                    False   \n",
       "\n",
       "   Job dissatisfaction  Dissatisfaction with the department  \\\n",
       "0                 True                                False   \n",
       "1                False                                False   \n",
       "2                False                                False   \n",
       "3                False                                False   \n",
       "4                False                                False   \n",
       "\n",
       "   Physical work environment  Lack of recognition  Lack of job security  \\\n",
       "0                      False                 True                 False   \n",
       "1                      False                False                 False   \n",
       "2                      False                False                 False   \n",
       "3                      False                False                 False   \n",
       "4                      False                False                 False   \n",
       "\n",
       "   Work location  Employment conditions  Maternity/family  Relocation  \\\n",
       "0          False                  False             False       False   \n",
       "1          False                  False             False       False   \n",
       "2          False                  False             False       False   \n",
       "3          False                  False             False       False   \n",
       "4          False                  False             False       False   \n",
       "\n",
       "   Study/Travel  Ill Health  Traumatic incident  Work life balance  Workload  \\\n",
       "0         False       False               False              False     False   \n",
       "1         False       False               False              False     False   \n",
       "2         False       False               False              False     False   \n",
       "3         False       False               False              False     False   \n",
       "4         False       False               False               True     False   \n",
       "\n",
       "   None of the above Professional Development Opportunities for promotion  \\\n",
       "0               True                        A                           A   \n",
       "1              False                        A                           A   \n",
       "2               True                        N                           N   \n",
       "3              False                        A                           N   \n",
       "4              False                        A                           A   \n",
       "\n",
       "  Staff morale Workplace issue Physical environment Worklife balance  \\\n",
       "0            N               N                    N                A   \n",
       "1            N               N                    N                N   \n",
       "2            N               N                    N                N   \n",
       "3            N               N                    A                A   \n",
       "4            N               N                    D                D   \n",
       "\n",
       "  Stress and pressure support Performance of supervisor Peer support  \\\n",
       "0                           A                         A            A   \n",
       "1                           A                         A            A   \n",
       "2                           N                         N            N   \n",
       "3                           N                         N            A   \n",
       "4                           N                         A            A   \n",
       "\n",
       "  Initiative Skills Coach Career Aspirations Feedback Further PD  \\\n",
       "0          N      N     N                  A        A          A   \n",
       "1          N      N     N                  A        A          A   \n",
       "2          N      N     N                  N        N          N   \n",
       "3          A      A     A                  A        A          A   \n",
       "4          A      A     A                  A       SA         SA   \n",
       "\n",
       "  Communication My say Information Kept informed Wellness programs  \\\n",
       "0             N      A           A             N                 N   \n",
       "1             N      A           A             N                 N   \n",
       "2             A      A           N             N                 N   \n",
       "3             A      A           A             A                 N   \n",
       "4             D      D           A             N                 A   \n",
       "\n",
       "  Health & Safety  Gender          Age Aboriginal Torres Strait South Sea  \\\n",
       "0               N    Male        56-60        NaN           NaN       NaN   \n",
       "1               N    Male        56-60        NaN           NaN       NaN   \n",
       "2               N    Male  61 or older        NaN           NaN       NaN   \n",
       "3               A  Female        36-40        NaN           NaN       NaN   \n",
       "4               M  Female  61 or older        NaN           NaN       NaN   \n",
       "\n",
       "  Disability NESB  \n",
       "0        NaN  Yes  \n",
       "1        NaN  NaN  \n",
       "2        NaN  NaN  \n",
       "3        NaN  NaN  \n",
       "4        NaN  NaN  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Read in the data again, but this time read `Not Stated` values as `NaN`\n",
    "dete_survey = pd.read_csv('dete_survey.csv', na_values='Not Stated')\n",
    "\n",
    "# Quick exploration of the data\n",
    "dete_survey.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['ID', 'SeparationType', 'Cease Date', 'DETE Start Date',\n",
      "       'Role Start Date', 'Position', 'Classification', 'Region',\n",
      "       'Business Unit', 'Employment Status', 'Career move to public sector',\n",
      "       'Career move to private sector', 'Interpersonal conflicts',\n",
      "       'Job dissatisfaction', 'Dissatisfaction with the department',\n",
      "       'Physical work environment', 'Lack of recognition',\n",
      "       'Lack of job security', 'Work location', 'Employment conditions',\n",
      "       'Maternity/family', 'Relocation', 'Study/Travel', 'Ill Health',\n",
      "       'Traumatic incident', 'Work life balance', 'Workload',\n",
      "       'None of the above', 'Gender', 'Age', 'Aboriginal', 'Torres Strait',\n",
      "       'South Sea', 'Disability', 'NESB'],\n",
      "      dtype='object')\n",
      "Index(['Record ID', 'Institute', 'WorkArea', 'CESSATION YEAR',\n",
      "       'Reason for ceasing employment',\n",
      "       'Contributing Factors. Career Move - Public Sector ',\n",
      "       'Contributing Factors. Career Move - Private Sector ',\n",
      "       'Contributing Factors. Career Move - Self-employment',\n",
      "       'Contributing Factors. Ill Health',\n",
      "       'Contributing Factors. Maternity/Family',\n",
      "       'Contributing Factors. Dissatisfaction',\n",
      "       'Contributing Factors. Job Dissatisfaction',\n",
      "       'Contributing Factors. Interpersonal Conflict',\n",
      "       'Contributing Factors. Study', 'Contributing Factors. Travel',\n",
      "       'Contributing Factors. Other', 'Contributing Factors. NONE',\n",
      "       'Gender. What is your Gender?', 'CurrentAge. Current Age',\n",
      "       'Employment Type. Employment Type', 'Classification. Classification',\n",
      "       'LengthofServiceOverall. Overall Length of Service at Institute (in years)',\n",
      "       'LengthofServiceCurrent. Length of Service at current workplace (in years)'],\n",
      "      dtype='object')\n"
     ]
    }
   ],
   "source": [
    "# Remove columns we don't need for our analysis\n",
    "dete_survey_updated = dete_survey.drop(dete_survey.columns[28:49], axis=1)\n",
    "tafe_survey_updated = tafe_survey.drop(tafe_survey.columns[17:66], axis=1)\n",
    "\n",
    "#Check that the columns were dropped\n",
    "print(dete_survey_updated.columns)\n",
    "print(tafe_survey_updated.columns)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Rename Columns\n",
    "\n",
    "Next, we'll standardize the names of the columns we want to work with, because we eventually want to combine the dataframes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['id', 'separationtype', 'cease_date', 'dete_start_date',\n",
       "       'role_start_date', 'position', 'classification', 'region',\n",
       "       'business_unit', 'employment_status', 'career_move_to_public_sector',\n",
       "       'career_move_to_private_sector', 'interpersonal_conflicts',\n",
       "       'job_dissatisfaction', 'dissatisfaction_with_the_department',\n",
       "       'physical_work_environment', 'lack_of_recognition',\n",
       "       'lack_of_job_security', 'work_location', 'employment_conditions',\n",
       "       'maternity/family', 'relocation', 'study/travel', 'ill_health',\n",
       "       'traumatic_incident', 'work_life_balance', 'workload',\n",
       "       'none_of_the_above', 'gender', 'age', 'aboriginal', 'torres_strait',\n",
       "       'south_sea', 'disability', 'nesb'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Clean the column names\n",
    "dete_survey_updated.columns = dete_survey_updated.columns.str.lower().str.strip().str.replace(' ', '_')\n",
    "\n",
    "# Check that the column names were updated correctly\n",
    "dete_survey_updated.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['id', 'Institute', 'WorkArea', 'cease_date', 'separationtype',\n",
       "       'Contributing Factors. Career Move - Public Sector ',\n",
       "       'Contributing Factors. Career Move - Private Sector ',\n",
       "       'Contributing Factors. Career Move - Self-employment',\n",
       "       'Contributing Factors. Ill Health',\n",
       "       'Contributing Factors. Maternity/Family',\n",
       "       'Contributing Factors. Dissatisfaction',\n",
       "       'Contributing Factors. Job Dissatisfaction',\n",
       "       'Contributing Factors. Interpersonal Conflict',\n",
       "       'Contributing Factors. Study', 'Contributing Factors. Travel',\n",
       "       'Contributing Factors. Other', 'Contributing Factors. NONE', 'gender',\n",
       "       'age', 'employment_status', 'position', 'institute_service',\n",
       "       'role_service'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Update column names to match the names in dete_survey_updated\n",
    "mapping = {'Record ID': 'id', 'CESSATION YEAR': 'cease_date', 'Reason for ceasing employment': 'separationtype', 'Gender. What is your Gender?': 'gender', 'CurrentAge. Current Age': 'age',\n",
    "       'Employment Type. Employment Type': 'employment_status',\n",
    "       'Classification. Classification': 'position',\n",
    "       'LengthofServiceOverall. Overall Length of Service at Institute (in years)': 'institute_service',\n",
    "       'LengthofServiceCurrent. Length of Service at current workplace (in years)': 'role_service'}\n",
    "tafe_survey_updated = tafe_survey_updated.rename(mapping, axis = 1)\n",
    "\n",
    "# Check that the specified column names were updated correctly\n",
    "tafe_survey_updated.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Filter the Data\n",
    "\n",
    "For this project, we'll only analyze survey respondents who *resigned*, so we'll only select separation types containing the string `'Resignation'`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Resignation                 340\n",
       "Contract Expired            127\n",
       "Retrenchment/ Redundancy    104\n",
       "Retirement                   82\n",
       "Transfer                     25\n",
       "Termination                  23\n",
       "Name: separationtype, dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values for the separationtype column\n",
    "tafe_survey_updated['separationtype'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Age Retirement                          285\n",
       "Resignation-Other reasons               150\n",
       "Resignation-Other employer               91\n",
       "Resignation-Move overseas/interstate     70\n",
       "Voluntary Early Retirement (VER)         67\n",
       "Ill Health Retirement                    61\n",
       "Other                                    49\n",
       "Contract Expired                         34\n",
       "Termination                              15\n",
       "Name: separationtype, dtype: int64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values for the separationtype column\n",
    "dete_survey_updated['separationtype'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Resignation                         311\n",
       "Age Retirement                      285\n",
       "Voluntary Early Retirement (VER)     67\n",
       "Ill Health Retirement                61\n",
       "Other                                49\n",
       "Contract Expired                     34\n",
       "Termination                          15\n",
       "Name: separationtype, dtype: int64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Update all separation types containing the word \"resignation\" to 'Resignation'\n",
    "dete_survey_updated['separationtype'] = dete_survey_updated['separationtype'].str.split('-').str[0]\n",
    "\n",
    "# Check the values in the separationtype column were updated correctly\n",
    "dete_survey_updated['separationtype'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Select only the resignation separation types from each dataframe\n",
    "dete_resignations = dete_survey_updated[dete_survey_updated['separationtype'] == 'Resignation'].copy()\n",
    "tafe_resignations = tafe_survey_updated[tafe_survey_updated['separationtype'] == 'Resignation'].copy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Verify the Data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Below, we clean and explore the `cease_date` and `dete_start_date` columns to make sure all of the years make sense. We'll use the following criteria:\n",
    "\n",
    "   - Since the `cease_date` is the last year of the person's employment and the `dete_start_date` is the person's first year of employment, it wouldn't make sense to have years after the current date. \n",
    "   - 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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012       126\n",
       "2013        74\n",
       "01/2014     22\n",
       "12/2013     17\n",
       "06/2013     14\n",
       "09/2013     11\n",
       "07/2013      9\n",
       "11/2013      9\n",
       "10/2013      6\n",
       "08/2013      4\n",
       "05/2012      2\n",
       "05/2013      2\n",
       "09/2010      1\n",
       "07/2006      1\n",
       "07/2012      1\n",
       "2010         1\n",
       "Name: cease_date, dtype: int64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values\n",
    "dete_resignations['cease_date'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2013.0    146\n",
       "2012.0    129\n",
       "2014.0     22\n",
       "2010.0      2\n",
       "2006.0      1\n",
       "Name: cease_date, dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Extract the years and convert them to a float type\n",
    "dete_resignations['cease_date'] = dete_resignations['cease_date'].str.split('/').str[-1]\n",
    "dete_resignations['cease_date'] = dete_resignations['cease_date'].astype(\"float\")\n",
    "\n",
    "# Check the values again and look for outliers\n",
    "dete_resignations['cease_date'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1963.0     1\n",
       "1971.0     1\n",
       "1972.0     1\n",
       "1984.0     1\n",
       "1977.0     1\n",
       "1987.0     1\n",
       "1975.0     1\n",
       "1973.0     1\n",
       "1982.0     1\n",
       "1974.0     2\n",
       "1983.0     2\n",
       "1976.0     2\n",
       "1986.0     3\n",
       "1985.0     3\n",
       "2001.0     3\n",
       "1995.0     4\n",
       "1988.0     4\n",
       "1989.0     4\n",
       "1991.0     4\n",
       "1997.0     5\n",
       "1980.0     5\n",
       "1993.0     5\n",
       "1990.0     5\n",
       "1994.0     6\n",
       "2003.0     6\n",
       "1998.0     6\n",
       "1992.0     6\n",
       "2002.0     6\n",
       "1996.0     6\n",
       "1999.0     8\n",
       "2000.0     9\n",
       "2013.0    10\n",
       "2009.0    13\n",
       "2006.0    13\n",
       "2004.0    14\n",
       "2005.0    15\n",
       "2010.0    17\n",
       "2012.0    21\n",
       "2007.0    21\n",
       "2008.0    22\n",
       "2011.0    24\n",
       "Name: dete_start_date, dtype: int64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values and look for outliers\n",
    "dete_resignations['dete_start_date'].value_counts().sort_values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2009.0      2\n",
       "2013.0     55\n",
       "2010.0     68\n",
       "2012.0     94\n",
       "2011.0    116\n",
       "Name: cease_date, dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values\n",
    "tafe_resignations['cease_date'].value_counts().sort_values()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Below are our findings:\n",
    "- The years in both dataframes don't completely align. The `tafe_survey_updated` dataframe contains some cease dates in 2009, but the `dete_survey_updated` dataframe does not. The `tafe_survey_updated` dataframe also contains many more cease dates in 2010 than the `dete_survey_updaed` dataframe. Since we aren't concerned with analyzing the results by year, we'll leave them as is."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Create a New Column\n",
    "\n",
    "Since our end goal is to answer the question below, we need a column containing the length of time an employee spent in their workplace, or years of service, in both dataframes.\n",
    "\n",
    "   - End goal: Are employees who have only worked for the institutes for a short period of time resigning due to some kind of dissatisfaction? What about employees who have been at the job longer?\n",
    "\n",
    "The `tafe_resignations` dataframe already contains a \"service\" column, which we renamed to `institute_service`.\n",
    "\n",
    "Below, we calculate the  years of service in the `dete_survey_updated` dataframe by subtracting the `dete_start_date` from the `cease_date` and create a new column named `institute_service`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3      7.0\n",
       "5     18.0\n",
       "8      3.0\n",
       "9     15.0\n",
       "11     3.0\n",
       "Name: institute_service, dtype: float64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Calculate the length of time an employee spent in their respective workplace and create a new column\n",
    "dete_resignations['institute_service'] = dete_resignations['cease_date'] - dete_resignations['dete_start_date']\n",
    "\n",
    "# Quick check of the result\n",
    "dete_resignations['institute_service'].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Identify Dissatisfied Employees\n",
    "Next, we'll identify any employees who resigned because they were dissatisfied. Below are the columns we'll use to categorize employees as \"dissatisfied\" from each dataframe:\n",
    "\n",
    "   1. tafe_survey_updated:\n",
    "       - `Contributing Factors. Dissatisfaction`\n",
    "       - `Contributing Factors. Job Dissatisfaction`\n",
    "   2.  dafe_survey_updated:\n",
    "       - `job_dissatisfaction`\n",
    "       - `dissatisfaction_with_the_department`\n",
    "       - `physical_work_environment`\n",
    "       - `lack_of_recognition`\n",
    "       - `lack_of_job_security`\n",
    "       - `work_location`\n",
    "       - `employment_conditions`\n",
    "       - `work_life_balance`\n",
    "       - `workload`\n",
    "    \n",
    "If the employee indicated any of the factors above caused them to resign, we'll mark them as `dissatisfied` in a new column. After our changes, the new `dissatisfied` column will contain just the following values:\n",
    "\n",
    "   - `True`: indicates a person resigned because they were dissatisfied in some way\n",
    "   - `False`: indicates a person resigned because of a reason other than dissatisfaction with the job\n",
    "   - `NaN`: indicates the value is missing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-                                         277\n",
       "Contributing Factors. Dissatisfaction      55\n",
       "Name: Contributing Factors. Dissatisfaction, dtype: int64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values\n",
    "tafe_resignations['Contributing Factors. Dissatisfaction'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-                      270\n",
       "Job Dissatisfaction     62\n",
       "Name: Contributing Factors. Job Dissatisfaction, dtype: int64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values\n",
    "tafe_resignations['Contributing Factors. Job Dissatisfaction'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False    241\n",
       "True      91\n",
       "NaN        8\n",
       "Name: dissatisfied, dtype: int64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Update the values in the contributing factors columns to be either True, False, or NaN\n",
    "def update_vals(x):\n",
    "    if x == '-':\n",
    "        return False\n",
    "    elif pd.isnull(x):\n",
    "        return np.nan\n",
    "    else:\n",
    "        return True\n",
    "tafe_resignations['dissatisfied'] = tafe_resignations[['Contributing Factors. Dissatisfaction', 'Contributing Factors. Job Dissatisfaction']].applymap(update_vals).any(1, skipna=False)\n",
    "tafe_resignations_up = tafe_resignations.copy()\n",
    "\n",
    "# Check the unique values after the updates\n",
    "tafe_resignations_up['dissatisfied'].value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False    162\n",
       "True     149\n",
       "Name: dissatisfied, dtype: int64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Update the values in columns related to dissatisfaction to be either True, False, or NaN\n",
    "dete_resignations['dissatisfied'] = dete_resignations[['job_dissatisfaction',\n",
    "       'dissatisfaction_with_the_department', 'physical_work_environment',\n",
    "       'lack_of_recognition', 'lack_of_job_security', 'work_location',\n",
    "       'employment_conditions', 'work_life_balance',\n",
    "       'workload']].any(1, skipna=False)\n",
    "dete_resignations_up = dete_resignations.copy()\n",
    "dete_resignations_up['dissatisfied'].value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Combining the Data\n",
    "\n",
    "Below, we'll add an institute column so that we can differentiate the data from each survey after we combine them. Then, we'll combine the dataframes and drop any remaining columns we don't need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Add an institute column\n",
    "dete_resignations_up['institute'] = 'DETE'\n",
    "tafe_resignations_up['institute'] = 'TAFE'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torres_strait                                            0\n",
       "south_sea                                                3\n",
       "aboriginal                                               7\n",
       "disability                                               8\n",
       "nesb                                                     9\n",
       "business_unit                                           32\n",
       "classification                                         161\n",
       "region                                                 265\n",
       "role_start_date                                        271\n",
       "dete_start_date                                        283\n",
       "role_service                                           290\n",
       "none_of_the_above                                      311\n",
       "work_life_balance                                      311\n",
       "traumatic_incident                                     311\n",
       "ill_health                                             311\n",
       "study/travel                                           311\n",
       "relocation                                             311\n",
       "maternity/family                                       311\n",
       "employment_conditions                                  311\n",
       "workload                                               311\n",
       "lack_of_job_security                                   311\n",
       "career_move_to_public_sector                           311\n",
       "career_move_to_private_sector                          311\n",
       "interpersonal_conflicts                                311\n",
       "work_location                                          311\n",
       "dissatisfaction_with_the_department                    311\n",
       "physical_work_environment                              311\n",
       "lack_of_recognition                                    311\n",
       "job_dissatisfaction                                    311\n",
       "Contributing Factors. Job Dissatisfaction              332\n",
       "Contributing Factors. Travel                           332\n",
       "Contributing Factors. Maternity/Family                 332\n",
       "Contributing Factors. Ill Health                       332\n",
       "Contributing Factors. Career Move - Self-employment    332\n",
       "Contributing Factors. Career Move - Private Sector     332\n",
       "Contributing Factors. Career Move - Public Sector      332\n",
       "Contributing Factors. Dissatisfaction                  332\n",
       "Contributing Factors. Other                            332\n",
       "Contributing Factors. Interpersonal Conflict           332\n",
       "Contributing Factors. NONE                             332\n",
       "Contributing Factors. Study                            332\n",
       "Institute                                              340\n",
       "WorkArea                                               340\n",
       "institute_service                                      563\n",
       "gender                                                 592\n",
       "age                                                    596\n",
       "employment_status                                      597\n",
       "position                                               598\n",
       "cease_date                                             635\n",
       "dissatisfied                                           643\n",
       "separationtype                                         651\n",
       "institute                                              651\n",
       "id                                                     651\n",
       "dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Combine the dataframes\n",
    "combined = pd.concat([dete_resignations_up, tafe_resignations_up], ignore_index=True)\n",
    "\n",
    "# Verify the number of non null values in each column\n",
    "combined.notnull().sum().sort_values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Drop columns with less than 500 non null values\n",
    "combined_updated = combined.dropna(thresh = 500, axis =1).copy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Clean the Service Column \n",
    "\n",
    "Next, we'll clean the `institute_service` column and categorize employees according to the following definitions:\n",
    "\n",
    " - New: Less than 3 years in the workplace\n",
    " - Experienced: 3-6 years in the workplace\n",
    " - Established: 7-10 years in the workplace\n",
    " - Veteran: 11 or more years in the workplace\n",
    " \n",
    "Our analysis is based on [this article](https://www.businesswire.com/news/home/20171108006002/en/Age-Number-Engage-Employees-Career-Stage), which makes the argument that understanding employee's needs according to career stage instead of age is more effective."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NaN                   88\n",
       "Less than 1 year      73\n",
       "1-2                   64\n",
       "3-4                   63\n",
       "5-6                   33\n",
       "11-20                 26\n",
       "5.0                   23\n",
       "1.0                   22\n",
       "7-10                  21\n",
       "0.0                   20\n",
       "3.0                   20\n",
       "6.0                   17\n",
       "4.0                   16\n",
       "2.0                   14\n",
       "9.0                   14\n",
       "7.0                   13\n",
       "More than 20 years    10\n",
       "8.0                    8\n",
       "13.0                   8\n",
       "15.0                   7\n",
       "20.0                   7\n",
       "12.0                   6\n",
       "22.0                   6\n",
       "17.0                   6\n",
       "10.0                   6\n",
       "14.0                   6\n",
       "18.0                   5\n",
       "16.0                   5\n",
       "23.0                   4\n",
       "24.0                   4\n",
       "11.0                   4\n",
       "39.0                   3\n",
       "21.0                   3\n",
       "32.0                   3\n",
       "19.0                   3\n",
       "36.0                   2\n",
       "30.0                   2\n",
       "26.0                   2\n",
       "28.0                   2\n",
       "25.0                   2\n",
       "29.0                   1\n",
       "31.0                   1\n",
       "49.0                   1\n",
       "33.0                   1\n",
       "34.0                   1\n",
       "35.0                   1\n",
       "38.0                   1\n",
       "41.0                   1\n",
       "42.0                   1\n",
       "27.0                   1\n",
       "Name: institute_service, dtype: int64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the unique values\n",
    "combined_updated['institute_service'].value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0     159\n",
       "3.0      83\n",
       "5.0      56\n",
       "7.0      34\n",
       "11.0     30\n",
       "0.0      20\n",
       "20.0     17\n",
       "6.0      17\n",
       "4.0      16\n",
       "9.0      14\n",
       "2.0      14\n",
       "13.0      8\n",
       "8.0       8\n",
       "15.0      7\n",
       "17.0      6\n",
       "10.0      6\n",
       "12.0      6\n",
       "14.0      6\n",
       "22.0      6\n",
       "16.0      5\n",
       "18.0      5\n",
       "24.0      4\n",
       "23.0      4\n",
       "39.0      3\n",
       "19.0      3\n",
       "21.0      3\n",
       "32.0      3\n",
       "28.0      2\n",
       "36.0      2\n",
       "25.0      2\n",
       "30.0      2\n",
       "26.0      2\n",
       "29.0      1\n",
       "38.0      1\n",
       "42.0      1\n",
       "27.0      1\n",
       "41.0      1\n",
       "35.0      1\n",
       "49.0      1\n",
       "34.0      1\n",
       "33.0      1\n",
       "31.0      1\n",
       "Name: institute_service_up, dtype: int64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Extract the years of service and convert the type to float\n",
    "combined_updated['institute_service_up'] = combined_updated['institute_service'].astype('str').str.extract(r'(\\d+)')\n",
    "combined_updated['institute_service_up'] = combined_updated['institute_service_up'].astype('float')\n",
    "\n",
    "# Check the years extracted are correct\n",
    "combined_updated['institute_service_up'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "New            193\n",
       "Experienced    172\n",
       "Veteran        136\n",
       "Established     62\n",
       "Name: service_cat, dtype: int64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Convert years of service to categories\n",
    "def transform_service(val):\n",
    "    if val >= 11:\n",
    "        return \"Veteran\"\n",
    "    elif 7 <= val < 11:\n",
    "        return \"Established\"\n",
    "    elif 3 <= val < 7:\n",
    "        return \"Experienced\"\n",
    "    elif pd.isnull(val):\n",
    "        return np.nan\n",
    "    else:\n",
    "        return \"New\"\n",
    "combined_updated['service_cat'] = combined_updated['institute_service_up'].apply(transform_service)\n",
    "\n",
    "# Quick check of the update\n",
    "combined_updated['service_cat'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Perform Some Initial Analysis "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally, we'll replace the missing values in the `dissatisfied` column with the most frequent value, `False`. Then, we'll calculate the percentage of employees who resigned due to dissatisfaction in each `service_cat` group and plot the results.\n",
    "\n",
    "Note that since we still have additional missing values left to deal with, this is meant to be an initial introduction to the analysis, *not* the final analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False    403\n",
       "True     240\n",
       "NaN        8\n",
       "Name: dissatisfied, dtype: int64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Verify the unique values\n",
    "combined_updated['dissatisfied'].value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Replace missing values with the most frequent value, False\n",
    "combined_updated['dissatisfied'] = combined_updated['dissatisfied'].fillna(False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7f6ef8b9c760>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 22996 characters]\n",
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Calculate the percentage of employees who resigned due to dissatisfaction in each category\n",
    "dis_pct = combined_updated.pivot_table(index='service_cat', values='dissatisfied')\n",
    "\n",
    "# Plot the results\n",
    "%matplotlib inline\n",
    "dis_pct.plot(kind='bar', rot=30)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From the initial analysis above, we can tentatively conclude that employees with 7 or more years of service are more likely to resign due to some kind of dissatisfaction with the job than employees with less than 7 years of service. However, we need to handle the rest of the missing data to finalize our analysis."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
