-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from dsih-artpark/anuja-working
added functions for preprocessing and standardisation
- Loading branch information
Showing
9 changed files
with
116 additions
and
36 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/epipipeline/preprocess/dengue/functions/map_columns.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import re | ||
|
||
def map_columns(colname:str, map_dict: dict) -> str: | ||
"""This function standardises column names using mapping in config file | ||
Args: | ||
colname (str): Current column in DataFrame | ||
map (dict): Dictionary mapping of preprocessed col names to standardised col names | ||
Returns: | ||
str: Standardised column name | ||
""" | ||
|
||
colname=re.sub(r"[^\w\s]","", colname.lstrip().rstrip().lower()) | ||
colname=re.sub(r"(\s+)"," ", colname) | ||
colname=re.sub(r"\s","_", colname) | ||
|
||
for key, values in map_dict.items(): | ||
if colname in values: | ||
return key | ||
return colname |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
src/epipipeline/standardise/dengue/functions/assign_uuid.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/epipipeline/standardise/dengue/functions/standardise_result.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import re | ||
import numpy as np | ||
|
||
def standardise_result(x) -> str: | ||
"""This function standardises results to positive or negative | ||
Args: | ||
x (str/int): Result in the raw dataset | ||
Returns: | ||
str: Negative, Positive or NaN | ||
""" | ||
if isinstance(x, str) or isinstance(x, int): | ||
if re.search(r"-ve|Neg|Negative|No|0", str(x), re.IGNORECASE): | ||
return "NEGATIVE" | ||
elif re.search(r"NS1|IgM|D|Yes|\+ve|Pos|Positive|1", str(x), re.IGNORECASE): | ||
return "POSITIVE" | ||
return np.nan | ||
|