TableOne
Project description
# tableone
tableone is a package for creating “Table 1” summary statistics for a patient population. It was inspired by the R package of the same name by Yoshida and Bohn.
[![Build Status](https://travis-ci.org/tompollard/tableone.svg?branch=master)](https://travis-ci.org/tompollard/tableone) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.837898.svg)](https://doi.org/10.5281/zenodo.837898) [![Documentation Status](https://readthedocs.org/projects/tableone/badge/?version=latest)](https://tableone.readthedocs.io/en/latest/?badge=latest) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/tableone/badges/installer/conda.svg)](https://conda.anaconda.org/conda-forge) [![PyPI version](https://badge.fury.io/py/tableone.svg)](https://badge.fury.io/py/tableone)
## Suggested citation
If you use tableone in your study, please cite the following paper:
> Tom J Pollard, Alistair E W Johnson, Jesse D Raffa, Roger G Mark; tableone: An open source Python package for producing summary statistics for research papers, JAMIA Open, [https://doi.org/10.1093/jamiaopen/ooy012](https://doi.org/10.1093/jamiaopen/ooy012)
## Documentation
For documentation, see: [http://tableone.readthedocs.io/en/latest/](http://tableone.readthedocs.io/en/latest/). An executable demonstration of the package is available as a Jupyter Notebook: [https://github.com/tompollard/tableone/blob/master/tableone.ipynb](https://github.com/tompollard/tableone/blob/master/tableone.ipynb). A paper describing our motivations for creating the package is available at: [https://doi.org/10.1093/jamiaopen/ooy012](https://doi.org/10.1093/jamiaopen/ooy012).
## A note for users of tableone
While we have tried to use best practices in creating this package, automation of even basic statistical tasks can be unsound if done without supervision. We encourage use of tableone alongside other methods of descriptive statistics and, in particular, visualization to ensure appropriate data handling.
It is beyond the scope of our documentation to provide detailed guidance on summary statistics, but as a primer we provide some considerations for choosing parameters when creating a summary table at: [http://tableone.readthedocs.io/en/latest/bestpractice.html](http://tableone.readthedocs.io/en/latest/bestpractice.html).
Guidance should be sought from a statistician when using `tableone` for a research study, especially prior to submitting the study for publication.
## Installation
To install the package with pip, run:
`pip install tableone`
To install this package with conda, run:
`conda install -c conda-forge tableone`
## Example usage
Import libraries:
`python from tableone import TableOne import pandas as pd `
Load sample data into a pandas dataframe:
`python url="https://raw.githubusercontent.com/tompollard/tableone/master/data/pn2012_demo.csv" data=pd.read_csv(url) `
Optionally, a list of columns to be included in Table 1:
`python columns = ['Age', 'SysABP', 'Height', 'Weight', 'ICU', 'death'] `
Optionally, a list of columns containing categorical variables:
`python categorical = ['ICU', 'death'] `
Optionally, a categorical variable for stratification, a list of non-normal variables, and a dictionary of alternative labels:
`python groupby = ['death'] nonnormal = ['Age'] labels={'death': 'mortality'} `
Create an instance of TableOne with the input arguments:
`python mytable = TableOne(data, columns, categorical, groupby, nonnormal, labels=labels, pval=False) `
Type the name of the instance in an interpreter:
`python mytable `
…which prints the following table to screen:
Grouped by mortality:
Tables can be exported to file in various formats, including LaTeX, CSV, and HTML. Files are exported by calling the to_format method on the tableone object. For example, mytable can be exported to a CSV named ‘mytable.csv’ with the following command:
`python mytable.to_csv('mytable.csv') `
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tableone-0.5.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e36846ee3e9a7970ae9974e349987c6f39bad713a21b57df1364c774422811e6 |
|
MD5 | cbed7cad8b8e4c5545c13a0127a92522 |
|
BLAKE2b-256 | 321d88f6a9d1178d8e523ef3e0885db11c887c780ce0fb2f3b6138b56d8b37d8 |