{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df = pd.read_csv('death_row_discritized.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "def to_string(tokens):\n",
    "    try:\n",
    "        return \" \".join(eval(tokens))\n",
    "    except:\n",
    "        return \"error\"\n",
    "    \n",
    "df['statement_string'] = df.apply(lambda x: to_string(x['last_statement']), axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "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>age_received</th>\n",
       "      <th>education_level</th>\n",
       "      <th>age_crime</th>\n",
       "      <th>occupation</th>\n",
       "      <th>prior_record</th>\n",
       "      <th>num_of_vic</th>\n",
       "      <th>main_crime</th>\n",
       "      <th>type_of_crime</th>\n",
       "      <th>weapon</th>\n",
       "      <th>co_defendants</th>\n",
       "      <th>...</th>\n",
       "      <th>vic_kid</th>\n",
       "      <th>vic_male</th>\n",
       "      <th>vic_female</th>\n",
       "      <th>vic_police</th>\n",
       "      <th>age</th>\n",
       "      <th>race</th>\n",
       "      <th>county</th>\n",
       "      <th>last_statement</th>\n",
       "      <th>time_spent</th>\n",
       "      <th>statement_string</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>twenties</td>\n",
       "      <td>some_highschool</td>\n",
       "      <td>twenties</td>\n",
       "      <td>laborer</td>\n",
       "      <td>yes</td>\n",
       "      <td>one</td>\n",
       "      <td>murder</td>\n",
       "      <td>other</td>\n",
       "      <td>other</td>\n",
       "      <td>no</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>35-45</td>\n",
       "      <td>white</td>\n",
       "      <td>El Paso</td>\n",
       "      <td>['yeah', 'first_person_pronoun', 'want', 'to',...</td>\n",
       "      <td>10+</td>\n",
       "      <td>yeah first_person_pronoun want to address the ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>no_highschool</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>other</td>\n",
       "      <td>yes</td>\n",
       "      <td>two+</td>\n",
       "      <td>murder</td>\n",
       "      <td>other</td>\n",
       "      <td>knife</td>\n",
       "      <td>no</td>\n",
       "      <td>...</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>35-45</td>\n",
       "      <td>black</td>\n",
       "      <td>Dallas</td>\n",
       "      <td>['umm', 'pamela', 'can', 'pronoun', 'hear', 'f...</td>\n",
       "      <td>10+</td>\n",
       "      <td>umm pamela can pronoun hear first_person_prono...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>no_highschool</td>\n",
       "      <td>twenties</td>\n",
       "      <td>other</td>\n",
       "      <td>yes</td>\n",
       "      <td>one</td>\n",
       "      <td>murder_robbery</td>\n",
       "      <td>gun</td>\n",
       "      <td>gun</td>\n",
       "      <td>yes</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>35-45</td>\n",
       "      <td>hispanic</td>\n",
       "      <td>Johnson</td>\n",
       "      <td>['its', 'on', 'september', 'th', 'kayla', 'and...</td>\n",
       "      <td>10_or_less</td>\n",
       "      <td>its on september th kayla and david first_pers...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>some_highschool</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>laborer</td>\n",
       "      <td>yes</td>\n",
       "      <td>two+</td>\n",
       "      <td>murder</td>\n",
       "      <td>other</td>\n",
       "      <td>knife</td>\n",
       "      <td>no</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>45+</td>\n",
       "      <td>white</td>\n",
       "      <td>Tarrant</td>\n",
       "      <td>['hi', 'ladies', 'first_person_pronoun', 'want...</td>\n",
       "      <td>10+</td>\n",
       "      <td>hi ladies first_person_pronoun wanted to tell ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>twenties</td>\n",
       "      <td>some_highschool</td>\n",
       "      <td>twenties</td>\n",
       "      <td>laborer</td>\n",
       "      <td>yes</td>\n",
       "      <td>one</td>\n",
       "      <td>murder_other</td>\n",
       "      <td>other</td>\n",
       "      <td>other</td>\n",
       "      <td>no</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>45+</td>\n",
       "      <td>white</td>\n",
       "      <td>Montgomery</td>\n",
       "      <td>['lord', 'forgive', 'pronoun', 'pronoun', 'don...</td>\n",
       "      <td>10+</td>\n",
       "      <td>lord forgive pronoun pronoun dont know what pr...</td>\n",
       "    </tr>\n",
       "    <tr>\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>...</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",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>561</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>unknown</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>other</td>\n",
       "      <td>unknown</td>\n",
       "      <td>one</td>\n",
       "      <td>murder_other</td>\n",
       "      <td>gun</td>\n",
       "      <td>gun</td>\n",
       "      <td>yes</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>45+</td>\n",
       "      <td>white</td>\n",
       "      <td>Lubbock</td>\n",
       "      <td>['i', 'pray', 'that', 'first_person_pronoun', ...</td>\n",
       "      <td>10+</td>\n",
       "      <td>i pray that first_person_pronoun family will r...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>562</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>unknown</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>other</td>\n",
       "      <td>yes</td>\n",
       "      <td>one</td>\n",
       "      <td>murder_other</td>\n",
       "      <td>gun</td>\n",
       "      <td>gun</td>\n",
       "      <td>no</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>35-45</td>\n",
       "      <td>white</td>\n",
       "      <td>Bell</td>\n",
       "      <td>['when', 'asked', 'if', 'pronoun', 'had', 'a',...</td>\n",
       "      <td>10_or_less</td>\n",
       "      <td>when asked if pronoun had a last statement pro...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>563</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>unknown</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>other</td>\n",
       "      <td>no</td>\n",
       "      <td>one</td>\n",
       "      <td>murder</td>\n",
       "      <td>other</td>\n",
       "      <td>other</td>\n",
       "      <td>no</td>\n",
       "      <td>...</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>35-45</td>\n",
       "      <td>white</td>\n",
       "      <td>Harris</td>\n",
       "      <td>['what', 'is', 'about', 'to', 'transpire', 'in...</td>\n",
       "      <td>10_or_less</td>\n",
       "      <td>what is about to transpire in a few moments is...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>564</td>\n",
       "      <td>twenties</td>\n",
       "      <td>no_highschool</td>\n",
       "      <td>twenties</td>\n",
       "      <td>laborer</td>\n",
       "      <td>yes</td>\n",
       "      <td>two+</td>\n",
       "      <td>murder</td>\n",
       "      <td>gun</td>\n",
       "      <td>gun</td>\n",
       "      <td>yes</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>18-34</td>\n",
       "      <td>white</td>\n",
       "      <td>Jefferson</td>\n",
       "      <td>['none']</td>\n",
       "      <td>10_or_less</td>\n",
       "      <td>none</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>565</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>highschool</td>\n",
       "      <td>thirty+</td>\n",
       "      <td>laborer</td>\n",
       "      <td>yes</td>\n",
       "      <td>one</td>\n",
       "      <td>murder_robbery</td>\n",
       "      <td>gun</td>\n",
       "      <td>gun</td>\n",
       "      <td>yes</td>\n",
       "      <td>...</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>35-45</td>\n",
       "      <td>black</td>\n",
       "      <td>Tarrant</td>\n",
       "      <td>['statement', 'to', 'the', 'media', 'first_per...</td>\n",
       "      <td>10_or_less</td>\n",
       "      <td>statement to the media first_person_pronoun at...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>566 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    age_received  education_level age_crime occupation prior_record  \\\n",
       "0       twenties  some_highschool  twenties    laborer          yes   \n",
       "1        thirty+    no_highschool   thirty+      other          yes   \n",
       "2        thirty+    no_highschool  twenties      other          yes   \n",
       "3        thirty+  some_highschool   thirty+    laborer          yes   \n",
       "4       twenties  some_highschool  twenties    laborer          yes   \n",
       "..           ...              ...       ...        ...          ...   \n",
       "561      thirty+          unknown   thirty+      other      unknown   \n",
       "562      thirty+          unknown   thirty+      other          yes   \n",
       "563      thirty+          unknown   thirty+      other           no   \n",
       "564     twenties    no_highschool  twenties    laborer          yes   \n",
       "565      thirty+       highschool   thirty+    laborer          yes   \n",
       "\n",
       "    num_of_vic      main_crime type_of_crime weapon co_defendants  ...  \\\n",
       "0          one          murder         other  other            no  ...   \n",
       "1         two+          murder         other  knife            no  ...   \n",
       "2          one  murder_robbery           gun    gun           yes  ...   \n",
       "3         two+          murder         other  knife            no  ...   \n",
       "4          one    murder_other         other  other            no  ...   \n",
       "..         ...             ...           ...    ...           ...  ...   \n",
       "561        one    murder_other           gun    gun           yes  ...   \n",
       "562        one    murder_other           gun    gun            no  ...   \n",
       "563        one          murder         other  other            no  ...   \n",
       "564       two+          murder           gun    gun           yes  ...   \n",
       "565        one  murder_robbery           gun    gun           yes  ...   \n",
       "\n",
       "    vic_kid vic_male vic_female vic_police    age      race      county  \\\n",
       "0        no       no        yes         no  35-45     white     El Paso   \n",
       "1       yes      yes        yes         no  35-45     black      Dallas   \n",
       "2        no       no        yes         no  35-45  hispanic     Johnson   \n",
       "3        no       no        yes         no    45+     white     Tarrant   \n",
       "4        no       no        yes         no    45+     white  Montgomery   \n",
       "..      ...      ...        ...        ...    ...       ...         ...   \n",
       "561      no      yes         no        yes    45+     white     Lubbock   \n",
       "562      no      yes         no        yes  35-45     white        Bell   \n",
       "563     yes      yes         no         no  35-45     white      Harris   \n",
       "564      no      yes        yes         no  18-34     white   Jefferson   \n",
       "565      no      yes         no         no  35-45     black     Tarrant   \n",
       "\n",
       "                                        last_statement  time_spent  \\\n",
       "0    ['yeah', 'first_person_pronoun', 'want', 'to',...         10+   \n",
       "1    ['umm', 'pamela', 'can', 'pronoun', 'hear', 'f...         10+   \n",
       "2    ['its', 'on', 'september', 'th', 'kayla', 'and...  10_or_less   \n",
       "3    ['hi', 'ladies', 'first_person_pronoun', 'want...         10+   \n",
       "4    ['lord', 'forgive', 'pronoun', 'pronoun', 'don...         10+   \n",
       "..                                                 ...         ...   \n",
       "561  ['i', 'pray', 'that', 'first_person_pronoun', ...         10+   \n",
       "562  ['when', 'asked', 'if', 'pronoun', 'had', 'a',...  10_or_less   \n",
       "563  ['what', 'is', 'about', 'to', 'transpire', 'in...  10_or_less   \n",
       "564                                           ['none']  10_or_less   \n",
       "565  ['statement', 'to', 'the', 'media', 'first_per...  10_or_less   \n",
       "\n",
       "                                      statement_string  \n",
       "0    yeah first_person_pronoun want to address the ...  \n",
       "1    umm pamela can pronoun hear first_person_prono...  \n",
       "2    its on september th kayla and david first_pers...  \n",
       "3    hi ladies first_person_pronoun wanted to tell ...  \n",
       "4    lord forgive pronoun pronoun dont know what pr...  \n",
       "..                                                 ...  \n",
       "561  i pray that first_person_pronoun family will r...  \n",
       "562  when asked if pronoun had a last statement pro...  \n",
       "563  what is about to transpire in a few moments is...  \n",
       "564                                               none  \n",
       "565  statement to the media first_person_pronoun at...  \n",
       "\n",
       "[566 rows x 21 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
