prepare_descriptive_table
prepare_descriptive_table(
df,
digits=(0, 3, 3, 3, 3, 3, 3, 3),
*,
caption='Descriptive Statistics',
)Report descriptive statistics for the numeric/logical variables of df.
For every numeric or logical column the function reports the number of non-missing observations, mean, standard deviation (ddof = 1), minimum, first quartile, median, third quartile and maximum.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Data frame containing at least one numeric/logical variable and two observations. | required |
| digits | Sequence[int | None] | Sequence of length 8 giving the number of decimals for each statistic column (N, Mean, Std. dev., Min., 25 %, Median, 75 %, Max.). A value of None drops that column from the output. |
(0, 3, 3, 3, 3, 3, 3, 3) |
| caption | str | Table title used for the Great Tables header. | 'Descriptive Statistics' |
Returns
| Name | Type | Description |
|---|---|---|
| DescriptiveTableResult | df (the statistics table) and gt (a Great Tables object). |
Examples
Basic — descriptive statistics for every numeric column of the panel:
import expdpy as ex
from expdpy.data import load_kuznets
df = load_kuznets()
ex.prepare_descriptive_table(df).gtAdvanced — set the decimals per statistic (None drops that column), add a caption, and read the tidy statistics frame back from .df:
result = ex.prepare_descriptive_table(
df,
digits=(0, 2, 2, None, None, 2, None, None),
caption="Kuznets panel",
)
result.gt
result.df.head()