console¶
Shared rich console.
The console is used for the output of scripts and examples; library code logs
instead of printing, see pkpdutils.log.
from pkpdutils.console import console, print_table
console.rule("Section", style="white")
console.print(result) # a result renders as the table of its samples
print_table(result.summary_table("individual", by="dose"), title="Parameters")
rich_table turns any data frame of the package (summary_table,
to_dataframe, flag_table, intervals, the ratio and interaction tables)
into a rich table, print_table prints it, and a ParameterResult renders
itself as one through the rich protocol (__rich__), so console.print(result)
shows the parameters of every sample with their units in the header.
Importing this module has no side effects on the interpreter. To get rich
representations in an interactive session, install them explicitly with
rich.pretty.install().
rich_table
¶
A rich table of a data frame, the console rendering of the tables of the package.
A string cell is written as it is (the cells of summary_table are
formatted strings already), a number is rounded to digits significant
digits with pkpdutils.result.format_number, a missing value is an empty
cell and a boolean is written as yes/no. Numeric columns are aligned to
the right, text columns to the left; the header carries the column names
of the frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
DataFrame
|
the table, e.g. of |
required |
title
|
str | None
|
the title above the table. |
None
|
digits
|
int
|
significant digits of the numeric cells. |
3
|
index
|
bool
|
whether the index of the frame is the first column. |
False
|
caption
|
str | None
|
a caption below the table. |
None
|
Returns:
| Type | Description |
|---|---|
Table
|
The table, to print with |
Table
|
another rich renderable. |
print_table
¶
Print a data frame as a rich table on the console.
The table of a script or an example: print_table(result.summary_table(
"individual", by="dose"), title="Pharmacokinetic parameters"). The frame
itself is unchanged; a manuscript takes it with to_csv, to_markdown or
to_latex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
DataFrame
|
the table. |
required |
title
|
str | None
|
the title above the table. |
None
|
digits
|
int
|
significant digits of the numeric cells. |
3
|
index
|
bool
|
whether the index of the frame is the first column. |
False
|
caption
|
str | None
|
a caption below the table. |
None
|
console
|
Console | None
|
the console to print on, the shared one by default. |
None
|