pharmpy.data package

Submodules

Module contents

Data

The PharmPy data package is a standalone package.

The main class is the PharmDataFrame which is a pandas DataFrame with some extras relevant to pharmacometrics.

Manipulation of stand alone datasets

Options for the data module

Option name

Default value

Type

Description

na_values

[-99]

List

Data values to be converted to NA when reading in data

na_rep

'-99'

str

Data value to convert NA to when writing data

class pharmpy.data.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?

exception pharmpy.data.DatasetError[source]

Bases: Exception

exception pharmpy.data.DatasetWarning[source]

Bases: Warning

class pharmpy.data.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]
pharmpy.data.read_csv(path_or_io, raw=False, parse_columns=())[source]

Read a csv with header into a PharmDataFrame

pharmpy.data.read_nonmem_dataset(path_or_io, raw=False, ignore_character='#', colnames=(), coltypes=None, drop=None, null_value='0', parse_columns=(), ignore=None, accept=None)[source]
Read a nonmem dataset from file

column types will be inferred from the column names

raw - minimal processing, data will be kept in string format. ignore_character colnames - List or tuple of names to give each column given in order. Names need to be unique drop - A list or tuple of booleans of which columns to drop null_value - Value to use for NULL, i.e. empty records or padding parse_columns - Only applicable when raw=True. A list of columns to parse. ignore/accept - List of ignore/accept expressions

The following postprocessing operations are done to a non-raw dataset 1. Convert ordinary floating point numbers to float64 2. Convert numbers of special fortran format to float64 3. Convert None, ‘.’, empty string to the NULL value 4. Convert Inf/NaN properly 5. Pad with null_token columns if $INPUT has more columns than the dataset 6. Strip away superfluous columns from the dataset