DataVariable#
- class pharmpy.model.DataVariable(name, type='unknown', scale='ratio', count=False, properties={})[source]#
Bases:
ImmutableInformation about one variable represented by data
For long format datasets a data column can contain multiple data variables.
- Parameters:
name (str) – Variable name. Not the same as the name of the column
type (str) – Type of variable (see the “type” attribute)
scale (str) – Scale of measurement (see the “scale” attribute)
count (bool) – True if count data or False otherwise
properties (dict) – Other properties of the variable (see the “properties” attribute)
Attributes Summary
Does the data variable represent count data
Variable name
Other properties of the DataVariable
Scale of measurement
Symbol having the variable name
Type of column
Methods Summary
create(name[, type, scale, count, properties])from_dict(d)get_property(property)Get a variable property with default if not defined
Check if the data variable is categorical
Check if the data variable is numerical
remove_property(property)Remove a property
replace(**kwargs)Replace properties and create a new DataVariable
set_property(property, value)Set the value for a property
to_dict()Attributes Documentation
- count#
Does the data variable represent count data
- name#
Variable name
- properties#
Other properties of the DataVariable
descriptor
Kind of data
descriptor
Description
age
Age (since birth)
body height
Human body height
body surface area
Body surface area (calculated)
body weight
Human body weight
lean body mass
Lean body mass
fat free mass
Fat free mass
time after dose
Time after dose
plasma concentration
Concentration of substance in blood plasma
subject identifier
Unique integer identifier for a subject
observation identifier
Unique integer identifier for an observation
pk measurement
Any kind of PK measurement
pd measurement
Any kind of PD measurement
unit
Unit of the data variable
Custom units are allowed, but units that are available in sympy.physics.units can be recognized.
categories
All possible values of categorical data
molar_mass
The molar mass of a substance in g/mol
- scale#
Scale of measurement
The statistical scale of measurement for the data variable. Can be one of ‘nominal’, ‘ordinal’, ‘interval’ and ‘rational’.
- symbol#
Symbol having the variable name
- type#
Type of column
type
Description
id
Individual identifier. Max one per DataFrame. All values have to be unique
idv
Independent variable. Max one per DataFrame.
dv
Observations of the dependent variable
dvid
Dependent variable ID
covariate
Covariate
dose
Dose amount
rate
Rate of infusion
additional
Number of additional doses
ii
Interdose interval
ss
Steady state dosing
event
0 = observation
mdv
0 = DV is observation value, 1 = DV is missing
admid
Administration ID
compartment
Compartment information (not yet exactly specified)
lloq
Lower limit of quantification
blq
Below limit of quantification indicator
unknown
Unkown type. This will be the default for columns that hasn’t been assigned a type
Methods Documentation
- get_property(property)[source]#
Get a variable property with default if not defined
- Parameters:
property (str) – The property to get
- Returns:
Any – The value of the property or its default value
Examples
>>> from pharmpy.model import DataVariable >>> var1 = DataVariable.create("WGT", properties={"unit": "kg"}) >>> var1.get_property("unit") kilogram >>> var2 = DataVariable.create("ID") >>> var2.get_property("unit") 1
- is_categorical()[source]#
Check if the data variable is categorical
- Returns:
bool – True if categorical (nominal or ordinal) and False otherwise.
See also
is_numericalCheck if the data variable is numerical
Examples
>>> from pharmpy.model import DataVariable >>> var1 = DataVariable.create("WGT", scale='ratio') >>> var1.is_categorical() False >>> var2 = DataVariable.create("ID", scale='nominal') >>> var2.is_categorical() True
- is_numerical()[source]#
Check if the data variable is numerical
- Returns:
bool – True if numerical (interval or ratio) and False otherwise.
See also
is_categoricalCheck if the data variable is categorical
Examples
>>> from pharmpy.model import DataVariable >>> var1 = DataVariable.create("WGT", scale='ratio') >>> var1.is_numerical() True >>> var2 = DataVariable.create("ID", scale='nominal') >>> var2.is_numerical() False
- remove_property(property)[source]#
Remove a property
- Parameters:
property (str) – The property to remove
- Returns:
DataVariable – The updated DataVariable
Examples
>>> from pharmpy.model import DataVariable >>> var1 = DataVariable.create("WGT", properties={"descriptor": "body weight"}) >>> var2 = var1.remove_property("body weight")
- set_property(property, value)[source]#
Set the value for a property
- Parameters:
property (str) – The property to set
value (Any) – Value for the property
- Returns:
DataVariable – The updated DataVariable
Examples
>>> from pharmpy.model import DataVariable >>> var1 = DataVariable.create("WGT") >>> var2 = var1.set_property("unit", "kg") >>> var2.get_property("unit") kilogram