tompollard / tableone

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

Calculate row percentages #108

Closed gothmania closed 3 years ago

gothmania commented 3 years ago

Hi,

Sometimes I want to calculate the row percentages instead of column percentages. For example,

Category Group A Group B
Cat 1 100 (25%) 300 (75%)
Cat 2 400 (67%) 200 (33%)

instead of

Category Group A Group B
Cat 1 100 (20%) 300 (60%)
Cat 2 400 (80%) 200 (40%)

Could you consider adding an argument like row_percent to specify categorical variables whose row percentages should be calculated?

Thanks a lot, Long

tompollard commented 3 years ago

Thanks Long, this is something that I've been meaning to implement for a while. I'll try to take a look soon.

tompollard commented 3 years ago

Thanks again for the suggestion @gothmania. There is a new "row_percent" argument in version 0.7.10: https://pypi.org/project/tableone/0.7.10/ (available in Conda soon). Please give it a try and let us know if you come across any issues!

gothmania commented 3 years ago

Hi Tom,

I just checked the new argument. It works perfect. Thanks a lot of your quick response.

Long