ColumnInfo#

class pharmpy.model.ColumnInfo(name, variable_mapping, variable_id=None, drop=False, datatype='float64')[source]#

Bases: Immutable

Information about one data column

Parameters:
  • name (str) – Column name

  • variable_mapping (Mapping[int, DataVariable]) – A single DataVariable or a Mapping from identifier column to the DataVariable

  • variable_id (str) – The DataVariable identifier column

  • drop (bool) – Should column be dropped (i.e. barred from being used)

  • datatype (str) – Pandas datatype or special Pharmpy datatype (see the “dtype” attribute)

Attributes Summary

datatype

Column datatype

drop

Should this column be dropped

name

Column name

symbol

Symbol having the column name

type

The type of the column.

variable

If the column represent a single DataVariable return it else raise

variable_id

Name of identifier column (e.g. DVID or ADMID).

variable_mapping

Mapping from value in identifier column to DataVariable

variables

All datavariables defined in this column

Methods Summary

convert_datatype_to_pd_dtype(datatype)

Convert Pharmpy datatype to pandas dtype

convert_pd_dtype_to_datatype(dtype)

Convert pandas dtype to Pharmpy datatype

create(name[, variable_mapping, ...])

from_dict(d)

is_integer()

Check if the column datatype is integral

replace(**kwargs)

Replace properties and create a new ColumnInfo

to_dict()

Attributes Documentation

datatype#

Column datatype

datatype

Description

Size

Range

NA allowed?

int8

Signed integer

8 bits

-128 to +127.

No

int16

Signed integer

16 bits

-32,768 to +32,767.

No

int32

Signed integer

32 bits

-2,147,483,648 to +2,147,483,647.

No

int64

Signed integer

64 bits

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

No

uint8

Unsigned integer

8 bits

0 to 256.

No

uint16

Unsigned integer

16 bit

0 to 65,535.

No

uint32

Unsigned integer

32 bit

0 to 4,294,967,295.

No

uint64

Unsigned integer

64 bit

0 to 18,446,744,073,709,551,615

No

float16

Binary float

16 bits

≈ ±6.55×10⁴

Yes

float32

Binary float

32 bits

≈ ±3.4×10³⁸

Yes

float64

Binary float

64 bits

≈ ±1.8×10³⁰⁸

Yes

float128

Binary float

128 bits

≈ ±1.2×10⁴⁹³²

Yes

nmtran-time

NM-TRAN time

n

No

nmtran-date

NM-TRAN date

n

No

str

General string

n

No

The default, and most common datatype, is float64.

drop#

Should this column be dropped

name#

Column name

symbol#

Symbol having the column name

type#

The type of the column. See DataVariable.type Note that all variables in one column must have the same type

variable#

If the column represent a single DataVariable return it else raise

variable_id#

Name of identifier column (e.g. DVID or ADMID)

variable_mapping#

Mapping from value in identifier column to DataVariable

variables#

All datavariables defined in this column

Methods Documentation

static convert_datatype_to_pd_dtype(datatype)[source]#

Convert Pharmpy datatype to pandas dtype

Parameters:

datatype (str) – String representing a Pharmpy datatype

Returns:

str – String representing a pandas dtype

Examples

>>> from pharmpy.model import ColumnInfo
>>> ColumnInfo.convert_datatype_to_pd_dtype("float64")
'float64'
>>> ColumnInfo.convert_datatype_to_pd_dtype("nmtran-date")
'str'
static convert_pd_dtype_to_datatype(dtype)[source]#

Convert pandas dtype to Pharmpy datatype

Parameters:

dtype (str) – String representing a pandas dtype

Returns:

str – String representing a Pharmpy datatype

Examples

>>> from pharmpy.model import ColumnInfo
>>> ColumnInfo.convert_pd_dtype_to_datatype("float64")
'float64'
classmethod create(name, variable_mapping=None, variable_id=None, drop=False, datatype='float64')[source]#
classmethod from_dict(d)[source]#
is_integer()[source]#

Check if the column datatype is integral

Returns:

bool – True if of integral datatype

See also

is_categorical

Check if the column data is categorical

Examples

>>> from pharmpy.model import ColumnInfo, DataVariable
>>> var = DataVariable.create("WGT", scale='ratio')
>>> col = ColumnInfo.create("WGT", var)
>>> col.is_integer()
False
replace(**kwargs)[source]#

Replace properties and create a new ColumnInfo

to_dict()[source]#