Data
Bundled dataset loaders
- openpkpd.data.load_theophylline()[source]
Load the 12-subject Boeckmann theophylline dataset.
- Return type:
- Returns:
NONMEMDataset with columns ID, TIME, AMT, DV, EVID, MDV, WT. 144 rows (12 dose events + 132 observations, 12 subjects × 11 timepoints).
NONMEMDataset
- class openpkpd.data.dataset.NONMEMDataset(df, source_path=None, ignore_char=None, column_map=<factory>)[source]
Bases:
objectA validated, preprocessed NONMEM dataset.
- After construction:
All columns are renamed to NONMEM standard names
Missing numeric values (-99 or user-specified) replaced with NaN
EVID column added (default 0 = observation) if absent
MDV column added based on EVID if absent
CMT column added (default 1) if absent
Rows sorted by ID, then TIME
- Parameters:
- classmethod from_csv(path, input_columns=None, ignore_char=None, missing_value=-99.0, sep=',', impute_covariates=None, impute_method='locf')[source]
Load a NONMEM dataset from a CSV file.
- Parameters:
path (
str) – Path to CSV file.input_columns (
list[str] |None) – Ordered list of standard column names (from $INPUT). If None, treat first row as header.ignore_char (
str|None) – Ignore lines where the first data character matches this.missing_value (
float) – Numeric value treated as missing (default -99).sep (
str) – Column separator (default comma; use r’s+’ for whitespace).impute_covariates (
list[str] |None) – Column names to impute after loading. WhenNone(default) no imputation is performed.impute_method (
str) – Imputation strategy passed toCovariateImputer:'locf'(default),'nocb','mean','median', or'knn'.
- Return type:
- classmethod from_dataframe(df, missing_value=-99.0, impute_covariates=None, impute_method='locf')[source]
Construct from an already-loaded pandas DataFrame.
- Parameters:
df (
DataFrame) – Input DataFrame.missing_value (
float) – Numeric sentinel for missing values (default -99).impute_covariates (
list[str] |None) – Column names to impute after preprocessing. WhenNone(default) no imputation is performed.impute_method (
str) – Imputation strategy:'locf'(default),'nocb','mean','median', or'knn'.
- Return type:
- property has_lloq: bool
Return True if an LLOQ column is present in the dataset.
The LLOQ column must exist and contain at least one non-NaN value for this property to return True.
- lloq_values(subject_id=None)[source]
Return LLOQ values for the dataset or a single subject.
Only observation rows (EVID=0, MDV=0) are returned. If no LLOQ column is present, an array of NaN is returned with the same length as the observation rows.