Name | tableone JSON |
Version |
0.9.1
JSON |
| download |
home_page | None |
Summary | tableone is a package for creating 'Table 1' summary statistics for a patient population. |
upload_time | 2024-06-16 04:06:46 |
maintainer | None |
docs_url | None |
author | Alistair Johnson, Jesse Raffa |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2017 Tom Pollard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
table 1
table one
clinical research
cohort
statistics
|
VCS |
|
bugtrack_url |
|
requirements |
anybadge
Jinja2
numpy
openpyxl
pandas
pyright
pytest-cov
scipy
statsmodels
tabulate
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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.
[![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/version.svg)](https://anaconda.org/conda-forge/tableone)
[![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 [on GitHub](https://github.com/tompollard/tableone/blob/master/tableone.ipynb) as a Jupyter Notebook. The easiest way to try out this notebook is to [open it in Google Colaboratory](https://colab.research.google.com/github/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*.
## Overview
At a high level, you can use the package as follows:
- Import the data into a pandas DataFrame
![Starting DataFrame ](https://raw.githubusercontent.com/tompollard/tableone/master/docs/images/input_data.png "Starting DataFrame")
- Run tableone on this dataframe to output summary statistics
![Table 1](https://raw.githubusercontent.com/tompollard/tableone/master/docs/images/table1.png "Table 1")
- Specify your desired output format: text, latex, markdown, etc.
![Export to LaTex](https://raw.githubusercontent.com/tompollard/tableone/master/docs/images/table1_latex.png "Export to LaTex")
Additional options include:
- Select a subset of columns.
- Specify the data type (e.g. `categorical`, `numerical`, `nonnormal`).
- Compute p-values, and adjust for multiple testing (e.g. with the Bonferroni correction).
- Compute standardized mean differences (SMDs).
- Provide a list of alternative labels for variables
- Limit the output of categorical variables to the top N rows.
- Display remarks relating to the appopriateness of summary measures (for example, computing tests for multimodality and normality).
## 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
1. Import libraries:
```python
from tableone import TableOne, load_dataset
import pandas as pd
```
2. Load sample data into a pandas dataframe:
```python
data=load_dataset('pn2012')
```
3. Optionally, a list of columns to be included in Table 1:
```python
columns = ['Age', 'SysABP', 'Height', 'Weight', 'ICU', 'death']
```
4. Optionally, a list of columns containing categorical variables:
```python
categorical = ['ICU', 'death']
```
5. Optionally, a list of columns containing continuous variables:
```python
continuous = ['Age', 'SysABP', 'Height', 'Weight']
```
6. Optionally, a categorical variable for stratification, a list of non-normal variables, and a dictionary of alternative labels:
```python
groupby = 'death'
nonnormal = ['Age']
rename={'death': 'mortality'}
```
7. Create an instance of TableOne with the input arguments:
```python
mytable = TableOne(data, columns=columns, categorical=categorical, continuous=continuous, groupby=groupby, nonnormal=nonnormal, rename=rename, pval=False)
```
8. Display the table using the `tabulate` method. The `tablefmt` argument allows the table to be displayed in multiple formats, including "github", "grid", "fancy_grid", "rst", "html", and "latex".
```python
print(mytable.tabulate(tablefmt = "fancy_grid"))
```
9. ...which prints the following table to screen:
Grouped by mortality:
| | | Missing | 0 | 1 |
| --------- | ------ | -------- | -------------- | -------------- |
| n | | | 864 | 136 |
| Age | | 0 | 66 [52,78] | 75 [62,83] |
| SysABP | | 291 | 115.36 (38.34) | 107.57 (49.43) |
| Height | | 475 | 170.33 (23.22) | 168.51 (11.31) |
| Weight | | 302 | 83.04 (23.58) | 82.29 (25.40) |
| ICU | CCU | 0 | 137 (15.86) | 25 (18.38) |
| | CSRU | | 194 (22.45) | 8 (5.88) |
| | MICU | | 318 (36.81) | 62 (45.59) |
| | SICU | | 215 (24.88) | 41 (30.15) |
| mortality | 0 | 0 | 864 (100.0) | |
| | 1 | | | 136 (100.0) |
10. 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 an Excel spreadsheet named 'mytable.xlsx' with the following command:
```python
mytable.to_excel('mytable.xlsx')
```
Raw data
{
"_id": null,
"home_page": null,
"name": "tableone",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "Table 1, Table one, clinical research, cohort, statistics",
"author": "Alistair Johnson, Jesse Raffa",
"author_email": "Tom Pollard <tpollard@mit.edu>",
"download_url": "https://files.pythonhosted.org/packages/ff/04/98b6c6a15940878649a086e1bd3009a2171164cec77249778ff6612b4bbc/tableone-0.9.1.tar.gz",
"platform": null,
"description": "# tableone \n\ntableone is a package for creating \"Table 1\" summary statistics for a patient \npopulation. It was inspired by the R package of the same name by Yoshida and \nBohn.\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.837898.svg)](https://doi.org/10.5281/zenodo.837898)\n[![Documentation Status](https://readthedocs.org/projects/tableone/badge/?version=latest)](https://tableone.readthedocs.io/en/latest/?badge=latest)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/tableone/badges/version.svg)](https://anaconda.org/conda-forge/tableone)\n[![PyPI version](https://badge.fury.io/py/tableone.svg)](https://badge.fury.io/py/tableone)\n\n## Suggested citation\n\nIf you use tableone in your study, please cite the following paper:\n\n> 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)\n\n## Documentation\n\nFor documentation, see: [http://tableone.readthedocs.io/en/latest/](http://tableone.readthedocs.io/en/latest/). An executable demonstration of the package is available [on GitHub](https://github.com/tompollard/tableone/blob/master/tableone.ipynb) as a Jupyter Notebook. The easiest way to try out this notebook is to [open it in Google Colaboratory](https://colab.research.google.com/github/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).\n\n## A note for users of `tableone`\n\nWhile 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. \n\nIt 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). \n\n*Guidance should be sought from a statistician when using `tableone` for a research study, especially prior to submitting the study for publication*.\n\n## Overview\n\nAt a high level, you can use the package as follows:\n\n- Import the data into a pandas DataFrame\n\n![Starting DataFrame ](https://raw.githubusercontent.com/tompollard/tableone/master/docs/images/input_data.png \"Starting DataFrame\")\n\n- Run tableone on this dataframe to output summary statistics\n \n![Table 1](https://raw.githubusercontent.com/tompollard/tableone/master/docs/images/table1.png \"Table 1\")\n\n- Specify your desired output format: text, latex, markdown, etc.\n \n![Export to LaTex](https://raw.githubusercontent.com/tompollard/tableone/master/docs/images/table1_latex.png \"Export to LaTex\")\n\nAdditional options include:\n\n- Select a subset of columns.\n- Specify the data type (e.g. `categorical`, `numerical`, `nonnormal`).\n- Compute p-values, and adjust for multiple testing (e.g. with the Bonferroni correction).\n- Compute standardized mean differences (SMDs).\n- Provide a list of alternative labels for variables\n- Limit the output of categorical variables to the top N rows.\n- Display remarks relating to the appopriateness of summary measures (for example, computing tests for multimodality and normality).\n\n## Installation\n\nTo install the package with pip, run:\n\n```pip install tableone```\n\nTo install this package with conda, run:\n \n```conda install -c conda-forge tableone```\n\n## Example usage\n\n1. Import libraries:\n\n```python\nfrom tableone import TableOne, load_dataset\nimport pandas as pd\n```\n\n2. Load sample data into a pandas dataframe:\n\n```python\ndata=load_dataset('pn2012')\n```\n\n3. Optionally, a list of columns to be included in Table 1:\n\n```python\ncolumns = ['Age', 'SysABP', 'Height', 'Weight', 'ICU', 'death']\n```\n\n4. Optionally, a list of columns containing categorical variables:\n\n```python\ncategorical = ['ICU', 'death']\n```\n\n5. Optionally, a list of columns containing continuous variables:\n\n```python\ncontinuous = ['Age', 'SysABP', 'Height', 'Weight']\n```\n\n6. Optionally, a categorical variable for stratification, a list of non-normal variables, and a dictionary of alternative labels:\n\n```python\ngroupby = 'death'\nnonnormal = ['Age']\nrename={'death': 'mortality'}\n```\n\n7. Create an instance of TableOne with the input arguments:\n\n```python\nmytable = TableOne(data, columns=columns, categorical=categorical, continuous=continuous, groupby=groupby, nonnormal=nonnormal, rename=rename, pval=False)\n```\n\n8. Display the table using the `tabulate` method. The `tablefmt` argument allows the table to be displayed in multiple formats, including \"github\", \"grid\", \"fancy_grid\", \"rst\", \"html\", and \"latex\".\n\n```python\nprint(mytable.tabulate(tablefmt = \"fancy_grid\"))\n```\n\n9. ...which prints the following table to screen:\n\nGrouped by mortality:\n\n| | | Missing | 0 | 1 | \n| --------- | ------ | -------- | -------------- | -------------- | \n| n | | | 864 | 136 |\n| Age | | 0 | 66 [52,78] | 75 [62,83] |\n| SysABP | | 291 | 115.36 (38.34) | 107.57 (49.43) |\n| Height | | 475 | 170.33 (23.22) | 168.51 (11.31) |\n| Weight | | 302 | 83.04 (23.58) | 82.29 (25.40) | \n| ICU | CCU | 0 | 137 (15.86) | 25 (18.38) |\n| | CSRU | | 194 (22.45) | 8 (5.88) | \n| | MICU | | 318 (36.81) | 62 (45.59) | \n| | SICU | | 215 (24.88) | 41 (30.15) | \n| mortality | 0 | 0 | 864 (100.0) | | \n| | 1 | | | 136 (100.0) | \n\n10. 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 an Excel spreadsheet named 'mytable.xlsx' with the following command:\n\n```python\nmytable.to_excel('mytable.xlsx')\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2017 Tom Pollard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "tableone is a package for creating 'Table 1' summary statistics for a patient population.",
"version": "0.9.1",
"project_urls": {
"documentation": "https://tableone.readthedocs.io/",
"homepage": "https://github.com/tompollard/tableone/",
"repository": "https://github.com/tompollard/tableone/"
},
"split_keywords": [
"table 1",
" table one",
" clinical research",
" cohort",
" statistics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b2019c40c5b80fef59e96f96c520767d9e6ddd5c46411ef2cff073782c79a1a5",
"md5": "270c73c9d0a29f0c82666c6715bdf43c",
"sha256": "b20994b0a63286ba1511d7ff691f42d6112e6ecbb773e020327d14dcdc9d44b7"
},
"downloads": -1,
"filename": "tableone-0.9.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "270c73c9d0a29f0c82666c6715bdf43c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 41565,
"upload_time": "2024-06-16T04:06:43",
"upload_time_iso_8601": "2024-06-16T04:06:43.705898Z",
"url": "https://files.pythonhosted.org/packages/b2/01/9c40c5b80fef59e96f96c520767d9e6ddd5c46411ef2cff073782c79a1a5/tableone-0.9.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ff0498b6c6a15940878649a086e1bd3009a2171164cec77249778ff6612b4bbc",
"md5": "9612d85cad78cff45c1d957c59a29230",
"sha256": "96c4b5b5820a204488e26c1ed88bbe8bec89ce5d128c11c3adab94bd26ac58e4"
},
"downloads": -1,
"filename": "tableone-0.9.1.tar.gz",
"has_sig": false,
"md5_digest": "9612d85cad78cff45c1d957c59a29230",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 770553,
"upload_time": "2024-06-16T04:06:46",
"upload_time_iso_8601": "2024-06-16T04:06:46.765683Z",
"url": "https://files.pythonhosted.org/packages/ff/04/98b6c6a15940878649a086e1bd3009a2171164cec77249778ff6612b4bbc/tableone-0.9.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-16 04:06:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tompollard",
"github_project": "tableone",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "anybadge",
"specs": [
[
"==",
"1.14.0"
]
]
},
{
"name": "Jinja2",
"specs": [
[
"==",
"3.1.4"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.23.2"
]
]
},
{
"name": "openpyxl",
"specs": [
[
"==",
"3.1.2"
]
]
},
{
"name": "pandas",
"specs": [
[
"==",
"2.0.3"
]
]
},
{
"name": "pyright",
"specs": [
[
"==",
"1.1.305"
]
]
},
{
"name": "pytest-cov",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "scipy",
"specs": [
[
"==",
"1.10.1"
]
]
},
{
"name": "statsmodels",
"specs": [
[
"==",
"0.14.1"
]
]
},
{
"name": "tabulate",
"specs": [
[
"==",
"0.9.0"
]
]
}
],
"lcname": "tableone"
}