tompollard / tableone

Create "Table 1" for research papers in Python
https://pypi.python.org/pypi/tableone/
MIT License
161 stars 38 forks source link

TableOne decimal argument #74

Closed PeterStrom closed 5 years ago

PeterStrom commented 5 years ago

Hi.

Would be very useful if TableOne had an argument for the number of decimals in the in the percentages e.g. n (%) = 5 (0.23), but with dec=1 would be 5 (0.2).

tompollard commented 5 years ago

@PeterStrom the latest release (v0.5.17) includes a decimals argument that allows you to set the number of decimal places reported for continuous and categorical variables.

    decimals : int or dict, optional
        Number of decimal places to display. An integer applies the rule to all
        variables (default: 1). A dictionary (e.g. `decimals = {'age': 0)`) applies 
        the rule per variable, defaulting to 1 place for unspecified variables.
        For continuous variables, applies to all summary statistics (e.g. mean and
        standard deviation). For categorical variables, applies to percentage only.

I hope this addresses the issue! Version 0.5.17 should be pip installable now, and it will be released on conda forge (https://anaconda.org/conda-forge/tableone) in the next day or two. The notebook includes an example of usage: https://github.com/tompollard/tableone/blob/master/tableone.ipynb

PeterStrom commented 5 years ago

Works! Big thanks!