pharmpy.data.data_frame module

class pharmpy.data.data_frame.ColumnType(value)[source]

Bases: enum.Enum

The type of the data in a column

COVARIATE = 5
DOSE = 6
DV = 4
EVENT = 7
ID = 2
IDV = 3
UNKNOWN = 1
property max_one

Can this ColumnType only be assigned to at most one column?

class pharmpy.data.data_frame.ColumnTypeIndexer(df)[source]

Bases: object

Indexing a PharmDataFrame to get or set column types An instance of ColumnTypeIndexer can be retrieved by df.pharmpy.column_type

class pharmpy.data.data_frame.DataFrameAccessor(obj)[source]

Bases: object

add_doseid()[source]

Add a column DOSEID with id of each dose period starting from 1

add_time_after_dose()[source]

Calculate and add a TAD column to the dataset

property baselines

Baselines for each id. Baseline is taken to be the first row even if that has a missing value.

property column_type
concentration_parameters()[source]

Create a dataframe with concentration parameters

property covariate_baselines

Return a dataframe with baselines of all covariates for each id. Baseline is taken to be the first row even if that has a missing value.

property doses

Return a series with all doses. Indexed with ID and TIME

property dv_label

Return the label of the dv column

generate_path(path=None, force=False)[source]

Generate the path of dataframe if written. If no path is supplied or does not contain a filename a name is created from the name property of the PharmDataFrame. Will not overwrite unless forced.

property id_label

Return the label of the id column

property ids

Return the ids in the dataset

property idv_label

Return the label of the idv column

property labels_by_type
property ninds
property nobs
property nobsi
property observations

Return a series with observations. Indexed with ID and TIME

property time_varying_covariates

Return a list of labels for all time varying covariates

write_csv(path=None, force=False)[source]

Write PharmDataFrame to a csv file return path for the written file

exception pharmpy.data.data_frame.DatasetError[source]

Bases: Exception

exception pharmpy.data.data_frame.DatasetWarning[source]

Bases: Warning

class pharmpy.data.data_frame.LabelsByTypeIndexer(acc)[source]

Bases: object

Indexing a PharmDataFrame to get labels from ColumnTypes

class pharmpy.data.data_frame.PharmDataFrame(data=None, index: Axes | None = None, columns: Axes | None = None, dtype: Dtype | None = None, copy: bool | None = None)[source]

Bases: pandas.core.frame.DataFrame

A DataFrame with additional metadata.

Each column can have a ColumnType. The default ColumnType is UNKNOWN.

ColumnType

Description

ID

Individual identifier. Max one per DataFrame. All values have to be unique

IDV

Independent variable. Max one per DataFrame.

DV

Dependent variable

COVARIATE

Covariate

DOSE

Dose amount

EVENT

0 = observation

UNKOWN

Unkown type. This will be the default for columns that hasn’t been assigned a type

copy(*kwargs)[source]
to_json(**kwargs)[source]

Inheritance Diagram

Inheritance diagram of pharmpy.data.data_frame