transform.collection_date(df, col: str)
Specimen Collection Date
Convert collection date column to a standardized date format
Usage
The function can be called into a .with_columns() statement. It will reference the dataframe’s status column and output a cleaned version of it.
Parameters
col : str
-
the sequence collection date column
df :
-
the dataframe of interest
Examples
For PHL/Template dates:
import polars as pl
import wadoh_subtyping.transform as tf
from wadoh_raccoon.utils import helpers
df = pl.DataFrame({
"submitted_date": [
'11/7/2021',
'12/10/2023',
None
]
})
# how to apply the function
df = (
df
.with_columns(
SPECIMEN_COLLECTION_DTTM=tf.collection_date(df,col="submitted_date")
)
)
# table output
helpers.gt_style(df_inp=df)
| 0 |
11/7/2021 |
2021-11-07 |
| 1 |
12/10/2023 |
2023-12-10 |
| 2 |
None |
None |