ADSL Namespace¶
The df.adam.adsl namespace builds one-row-per-subject ADSL datasets.
fleet.adam.ADSLNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADSL (one-row-per-subject) derivations.
Also registered as the adsl LazyFrame namespace, so
pl.scan_parquet(...).adsl starts a fully lazy ADSL pipeline.
Inherits shared verbs from SharedADaMVerbsMixin
(assign, case_when, merge, source, derivation, whereclauses, ...)
and adds ADSL-specific verbs that pull summary statistics from
event-level datasets (AE, CM, MH, EX…). Discover the full set with
.verbs().
Source code in src/fleet/adam/adsl_namespace.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
age_years
¶
Convert age to years, handling common unit strings.
Recognises AGEU values: YEARS, MONTHS, WEEKS, DAYS
(case-insensitive). Unknown units produce null. The value keeps full
precision (AGE 7 MONTHS gives 0.5833...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column (default |
'AAGE'
|
age_col
|
str
|
Source age column. |
'AGE'
|
age_unit_col
|
str
|
Column containing the age unit string. |
'AGEU'
|
round_digits
|
int | None
|
Decimal places, rounded as SAS |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
References
admiral compute_age_years (pharmaverse): full precision; one year is
12 months, 52.1775 weeks or 365.25 days.
ADR-0025: a derived value is rounded only when the call says so.
Examples:
Derive age in years from DM variables::
adsl = (
dm_raw.adam.adsl
.age_years("AAGE", age_col="AGE", age_unit_col="AGEU")
.to_frame()
)
Source code in src/fleet/adam/adsl_namespace.py
age_from_dates
¶
age_from_dates(
target="AAGE",
*,
birth_date="BRTHDT",
reference_date="TRTSDT",
unit="years",
round_digits=None
)
Compute age from two date columns, in completed years by default.
unit="years" gives whole completed years (Int64): the year
difference, minus 1 when the birthday of the reference year is not
yet reached. A subject born 1956-06-01 is 64 on 2021-05-31. A 29
February birthday is reached on 1 March in a non-leap year. A
reference date before birth gives a negative age.
unit="decimal" gives days / 365.25 at full precision. Null when
either date is missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column (default |
'AAGE'
|
birth_date
|
str
|
Date-of-birth column ( |
'BRTHDT'
|
reference_date
|
str
|
Reference date column ( |
'TRTSDT'
|
unit
|
Literal['years', 'decimal']
|
|
'years'
|
round_digits
|
int | None
|
Decimal places for |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
VerbUsageError
|
When round_digits is given with
|
References
admiral derive_vars_aage (pharmaverse) and SAS
FLOOR(YRDIF(BRTHDT, TRTSDT, 'AGE')): completed years. ICH E7 and
E11 age bands use completed years. ADR-0025.
Examples:
Derive age from birth and randomisation dates::
adsl = (
dm_raw.adam.adsl
.age_from_dates("AAGE", birth_date="BRTHDT",
reference_date="RANDDT")
.to_frame()
)
Source code in src/fleet/adam/adsl_namespace.py
derive_period
¶
Create standard Subperiod / Phase variables.
Generates AP{nn}SDT, AP{nn}EDT, and optionally
TRT{nn:02d}P columns for each period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
periods
|
list[dict[str, Any]]
|
List of dicts each with |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with period columns appended. |
Examples:
Define two treatment periods::
adsl = (
dm_raw.adam.adsl
.derive_period(
periods=[
{"number": 1, "start": "AP01SDT",
"end": "AP01EDT", "treatment": "TRT01P"},
{"number": 2, "start": "AP02SDT",
"end": "AP02EDT", "treatment": "TRT02P"},
],
)
.to_frame()
)
Source code in src/fleet/adam/adsl_namespace.py
options: show_root_heading: true heading_level: 2 members_order: source filters: ["!^_"]