eds_scikit.utils.process_table
tag_table_by_type
tag_table_by_type(table: DataFrame, type_groups: Union[str, Dict], source_col: str, target_col: str, filter_table: bool = False)
Add tag column to table based on their value (ex : condition_occurrence -> "DIABETIC", "NOT DIABETIC)
PARAMETER | DESCRIPTION |
---|---|
table |
Table (must contain columns source_col, target_col)
TYPE:
|
type_groups |
Regex or Dict of regex to define tags and associated regex.
TYPE:
|
source_col |
Column on which the tagging is applied.
TYPE:
|
target_col |
Label column name
TYPE:
|
remove_other |
If True, remove untagged columns
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
Input dataframe with tag column |
Output
person_id | condition_source_value | DIABETIC_CONDITION |
---|---|---|
001 | E100 | DIABETES_TYPE_I |
002 | E101 | DIABETES_TYPE_I |
003 | E110 | DIABETES_TYPE_II |
004 | E113 | DIABETES_TYPE_II |
005 | A001 | OTHER |
Source code in eds_scikit/utils/process_table.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
tag_table_period_length
tag_table_period_length(table: DataFrame, length_of_stays: List[float], start_date_col: str = 'visit_start_datetime', end_date_col: str = 'visit_end_datetime') -> DataFrame
Tag table by length of stays (can be applied to visit_occurrence table)
Example : length_of_stays = [7, 14]
Output
person_id | visit_start_datetime | visit_end_datetime | length_of_stay |
---|---|---|---|
001 | 2020-04-01 | 2020-04-12 | "7 days - 14 days" |
002 | 2020-04-01 | 2020-04-03 | "<= 7 days " |
003 | 2020-04-01 | 2020-04-09 | ">= 7 days " |
PARAMETER | DESCRIPTION |
---|---|
table |
TYPE:
|
length_of_stays |
Example : [7 , 14]
TYPE:
|
start_date_col |
by default "visit_start_datetime"
TYPE:
|
end_date_col |
by default "visit_end_datetime"
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
Source code in eds_scikit/utils/process_table.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
tag_table_with_age
tag_table_with_age(table: DataFrame, date_col: str, person: DataFrame, age_ranges: List[int] = None)
Tag table with person age
PARAMETER | DESCRIPTION |
---|---|
table |
must contain person_id and date_col
TYPE:
|
date_column |
date column from table on which to compute age
|
person |
must contain person_id
TYPE:
|
age_ranges |
if None, simply compute age. example : None, [18], [18, 60]
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
Source code in eds_scikit/utils/process_table.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|