specimen_source_site

transform.specimen_source_site(spec_source_col: str)

WDRS Specimen Type

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

spec_source_col : str

specimen source column

Examples

import polars as pl
import wadoh_subtyping.transform as tf
from wadoh_raccoon.utils import helpers

df = pl.DataFrame({
    "submitter": ["PHL", "PHL", "PHL"],
    "SpecimenSource": [
        "Resipiratory: nasal swab",
        "Nasopharyngeal Swab (NP)",
        "Conjunctival Swab"
    ]
})

# here's how to apply the function to a dataframe
df = (
    df
    .with_columns(
        SPECIMEN_SOURCE_SITE=tf.specimen_source_site(spec_source_col='SpecimenSource')
    )
)

# here's a table of the results
helpers.gt_style(df_inp=df)
index submitter SpecimenSource SPECIMEN_SOURCE_SITE
0 PHL Resipiratory: nasal swab None
1 PHL Nasopharyngeal Swab (NP) Nasopharyngeal (NP) swab
2 PHL Conjunctival Swab Eye