Closed tompollard closed 4 years ago
instead of this being a boolean argument, it should perhaps take a list of variables that should display min_max.
min_max now takes a list instead of a boolean. e.g.
from tableone import TableOne, load_dataset
data = load_dataset('pn2012')
columns = ['Age', 'SysABP', 'Height', 'Weight', 'ICU', 'death']
# columns containing categorical variables
categorical = ['ICU']
# set decimal places for age to 0
decimals = {"Age": 0}
# non-normal variables
nonnormal = ['Age']
# optionally, a categorical variable for stratification
groupby = ['death']
t1 = TableOne(data, columns=columns, categorical=categorical,
groupby=groupby, nonnormal=nonnormal, decimals=decimals,
min_max=['Age'])
print(t1.tabulate(tablefmt="github"))
Missing | Overall | 0 | 1 | ||
---|---|---|---|---|---|
n | 1000 | 864 | 136 | ||
Age, median [min,max] | 0 | 68 [16,90] | 66 [16,90] | 75 [26,90] | |
SysABP, mean (SD) | 291 | 114.3 (40.2) | 115.4 (38.3) | 107.6 (49.4) | |
Height, mean (SD) | 475 | 170.1 (22.1) | 170.3 (23.2) | 168.5 (11.3) | |
Weight, mean (SD) | 302 | 82.9 (23.8) | 83.0 (23.6) | 82.3 (25.4) | |
ICU, n (%) | CCU | 0 | 162 (16.2) | 137 (15.9) | 25 (18.4) |
CSRU | 202 (20.2) | 194 (22.5) | 8 (5.9) | ||
MICU | 380 (38.0) | 318 (36.8) | 62 (45.6) | ||
SICU | 256 (25.6) | 215 (24.9) | 41 (30.1) |
Patch by Vincent Lequertier to add a min_max argument to optionally use minimum and maximum values instead of Q1-Q3 for non-continuous variables. Ref #95.