In [ ]:
 
In [ ]:
 
In [2]:
import pandas as pd
df = pd.read_csv('death_row_discritized.csv')
In [28]:
def to_string(tokens):
    try:
        return " ".join(eval(tokens))
    except:
        return "error"
    
df['statement_string'] = df.apply(lambda x: to_string(x['last_statement']), axis=1)
In [29]:
df
Out[29]:
age_received education_level age_crime occupation prior_record num_of_vic main_crime type_of_crime weapon co_defendants ... vic_kid vic_male vic_female vic_police age race county last_statement time_spent statement_string
0 twenties some_highschool twenties laborer yes one murder other other no ... no no yes no 35-45 white El Paso ['yeah', 'first_person_pronoun', 'want', 'to',... 10+ yeah first_person_pronoun want to address the ...
1 thirty+ no_highschool thirty+ other yes two+ murder other knife no ... yes yes yes no 35-45 black Dallas ['umm', 'pamela', 'can', 'pronoun', 'hear', 'f... 10+ umm pamela can pronoun hear first_person_prono...
2 thirty+ no_highschool twenties other yes one murder_robbery gun gun yes ... no no yes no 35-45 hispanic Johnson ['its', 'on', 'september', 'th', 'kayla', 'and... 10_or_less its on september th kayla and david first_pers...
3 thirty+ some_highschool thirty+ laborer yes two+ murder other knife no ... no no yes no 45+ white Tarrant ['hi', 'ladies', 'first_person_pronoun', 'want... 10+ hi ladies first_person_pronoun wanted to tell ...
4 twenties some_highschool twenties laborer yes one murder_other other other no ... no no yes no 45+ white Montgomery ['lord', 'forgive', 'pronoun', 'pronoun', 'don... 10+ lord forgive pronoun pronoun dont know what pr...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
561 thirty+ unknown thirty+ other unknown one murder_other gun gun yes ... no yes no yes 45+ white Lubbock ['i', 'pray', 'that', 'first_person_pronoun', ... 10+ i pray that first_person_pronoun family will r...
562 thirty+ unknown thirty+ other yes one murder_other gun gun no ... no yes no yes 35-45 white Bell ['when', 'asked', 'if', 'pronoun', 'had', 'a',... 10_or_less when asked if pronoun had a last statement pro...
563 thirty+ unknown thirty+ other no one murder other other no ... yes yes no no 35-45 white Harris ['what', 'is', 'about', 'to', 'transpire', 'in... 10_or_less what is about to transpire in a few moments is...
564 twenties no_highschool twenties laborer yes two+ murder gun gun yes ... no yes yes no 18-34 white Jefferson ['none'] 10_or_less none
565 thirty+ highschool thirty+ laborer yes one murder_robbery gun gun yes ... no yes no no 35-45 black Tarrant ['statement', 'to', 'the', 'media', 'first_per... 10_or_less statement to the media first_person_pronoun at...

566 rows × 21 columns

In [ ]: