Beispiel #1
0
def test_word_existence_counts_per_word(df):
    try:
        df_fever = verbal_autopsy_functions.counts_per_word(
            df, 'word_nonexisting')
    except KeyError:
        print('Non-existing word causes an error.')
Beispiel #2
0
def test_type_counts_per_word_output(df):
    df_fever = verbal_autopsy_functions.counts_per_word(df, 'word_fever')
    if type(df_fever) is not pd.core.frame.DataFrame:
        print('The  output of the type is not a data frame.')
Beispiel #3
0
def test_columns_counts_per_word_output(df):
    df_fever = verbal_autopsy_functions.counts_per_word(df, 'word_fever')
    if list(df_fever.columns.values) != [
            'site', 'Cause of death', 'Times word_fever is mentioned.'
    ]:
        print('The column names are not as expected.')
Beispiel #4
0
# -------------------------------------------
# Loading the verbal autopsy analysis module
# -------------------------------------------
import verbal_autopsy_functions
import imp

imp.reload(verbal_autopsy_functions)

# -------------------------------------------
# Reading the data
# -------------------------------------------

# creating the data path
data_path = os.path.join(os.getcwd(), '..', 'data')

# reading the data files
df = pd.read_csv(os.path.join(data_path,
                              'IHME_PHMRC_VA_DATA_ADULT_Y2013M09D11_0.csv'),
                 low_memory=False)
cb = pd.read_excel(
    os.path.join(data_path, 'IHME_PHMRC_VA_DATA_CODEBOOK_Y2013M09D11_0.xlsx'))

# creating the results path
results_path = os.path.join(os.getcwd(), '..', 'results')

# calclulate the counts table for each word and write it to a csv file
for word in ['word_asthma', 'word_fever', 'word_cough']:
    table_counts = verbal_autopsy_functions.counts_per_word(df, word)
    table_counts.to_csv(os.path.join(results_path, word + '.csv'))
# -------------------------------------------
import verbal_autopsy_functions
import imp
imp.reload(verbal_autopsy_functions)



# -------------------------------------------
# Reading the data
# -------------------------------------------

# creating the data path
data_path = os.path.join(os.getcwd(),'..','data')


# reading the data files
df = pd.read_csv(os.path.join(data_path,'IHME_PHMRC_VA_DATA_ADULT_Y2013M09D11_0.csv'),low_memory = False)
cb = pd.read_excel(os.path.join(data_path,'IHME_PHMRC_VA_DATA_CODEBOOK_Y2013M09D11_0.xlsx'))


# creating the results path
results_path = os.path.join(os.getcwd(),'..','results')

# calclulate the counts table for each word and write it to a csv file
for word in ['word_asthma','word_fever','word_cough']:
   table_counts = verbal_autopsy_functions.counts_per_word(df,word)
   table_counts.to_csv(os.path.join(results_path,word+'.csv'))



def test_word_existence_counts_per_word(df):
    try:
        df_fever = verbal_autopsy_functions.counts_per_word(df,'word_nonexisting')
    except KeyError:
        print ('Non-existing word causes an error.')
def test_columns_counts_per_word_output(df):
    df_fever = verbal_autopsy_functions.counts_per_word(df,'word_fever')
    if list(df_fever.columns.values)!=['site', 'Cause of death','Times word_fever is mentioned.']:
        print ('The column names are not as expected.')
def test_type_counts_per_word_output(df):
    df_fever = verbal_autopsy_functions.counts_per_word(df,'word_fever')
    if type(df_fever) is not pd.core.frame.DataFrame:
        print ('The  output of the type is not a data frame.')