Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary Variables #111

Open
jpoles1 opened this issue Jan 14, 2021 · 5 comments
Open

Binary Variables #111

jpoles1 opened this issue Jan 14, 2021 · 5 comments

Comments

@jpoles1
Copy link

jpoles1 commented Jan 14, 2021

It would be nice if there was a way to display binary variables, other than making them categorical, in which case both True and False are shown. The ideal would be to have just the values for the "True" category displayed, I think it would look far more professional!

image

@jpoles1
Copy link
Author

jpoles1 commented Jan 14, 2021

I tried looking into the TableOne code a bit, and it's looking like a PR is something I don't have quite enough time for right now, unfortunately. For anyone looking for a quick and dirty solution, you can do the following:

table1 = TableOne()
table1 = table1.tableone #access underlying pandas df
table1 = table1[table1.index.get_level_values(1) != "False"] #Remove rows with "False"
table1.rename(index={"True": ""}, inplace=True) #Rename "True" to blank

and now it works perfectly!

image

PS: If you want to make your reformatted tables look pretty, you can use some css styles as below:

table1 = table1.style.set_table_styles(table_styles)
display(HTML(table1.render()))

@tompollard
Copy link
Owner

Thanks @jpoles1, we'll take a look at implementing this!

@raheems
Copy link

raheems commented Jan 15, 2021

You wouldn't believe that I started to post this exact feature request a few days ago and then decided not to post it :)

I did solve it using pandas as suggested. But I would appreciate if this feature is added :)

@jpoles1
Copy link
Author

jpoles1 commented Jan 15, 2021

Thanks @jpoles1, we'll take a look at implementing this!

Awesome, thanks such much for the great work on this lib!

@dnatanov
Copy link

Is there a way to include p values when only displaying the True binary variables? When I used the "quick and dirty" method to only include the binary variables listed as True, the calculated p values were removed from the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants