File size: 682 Bytes
53a6def
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
Comorbidities processing utilities
"""
import pandas as pd


def diagnosis_mapping_lists(excel_file, sheet_name, diagnosis_names):
    """
    Create mapping between diagnoses and comorbidities
    --------
    :param excel_file: str filename for diagnosis mapping
    :param sheet_name: str sheet name for diagnosis mapping
    :param diagnosis_names: str list of diagnoses
    :return: dictionary of diagnosis names and values
    """
    df_diag = pd.read_excel(excel_file, sheet_name, skiprows=range(0, 1))
    df_lists = df_diag.T.values.tolist()
    diag_lists = [[s.strip() for s in x if pd.notna(s)] for x in df_lists]

    return dict(zip(diagnosis_names, diag_lists))