Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
BICF
KCE
kce_etl
Commits
09331567
Commit
09331567
authored
Apr 22, 2020
by
Venkat Malladi
Browse files
Take maximum value for lab on day.
parent
656170c6
Pipeline
#6648
failed with stage
in 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
scripts/transform_labs.py
View file @
09331567
...
...
@@ -180,6 +180,13 @@ def calculate_shift(labs, date_shift):
return
merged
def
calculate_maximum
(
labs
):
'''Get maximum lab value for a given day'''
labs_max
=
labs
.
loc
[
labs
.
groupby
([
'mrn'
,
'date'
,
'lab'
])[
'value'
].
idxmax
()]
return
labs_max
def
main
():
args
=
get_args
()
labs
=
args
.
file
...
...
@@ -213,8 +220,11 @@ def main():
# Calculate Date Shift
shifted_df
=
calculate_shift
(
labs_flag
,
date_shift
)
# Filter and get maximum lab value for shifted date
max_lab
=
calculate_maximum
(
shifted_df
)
# Write out lab table
shifted_df
.
to_csv
(
lab_table
,
index
=
False
)
max_lab
.
to_csv
(
lab_table
,
index
=
False
)
# Write out unmapped sites if there are any
if
unmapped_labs
.
shape
[
0
]
>
1
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment