-
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.
MINOR: added standardise_result function
- Loading branch information
1 parent
e18fe81
commit 7fdd330
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
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 | ||
|