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

Add argument for continuous variables #167

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,33 @@ columns = ['Age', 'SysABP', 'Height', 'Weight', 'ICU', 'death']
categorical = ['ICU', 'death']
```

5. Optionally, a categorical variable for stratification, a list of non-normal variables, and a dictionary of alternative labels:
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']
labels={'death': 'mortality'}
```

6. Create an instance of TableOne with the input arguments:
7. Create an instance of TableOne with the input arguments:

```python
mytable = TableOne(data, columns=columns, categorical=categorical, groupby=groupby, nonnormal=nonnormal, rename=labels, pval=False)
mytable = TableOne(data, columns=columns, categorical=categorical, continuous=continuous, groupby=groupby, nonnormal=nonnormal, rename=labels, pval=False)
```

7. 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".
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"))
```

8. ...which prints the following table to screen:
9. ...which prints the following table to screen:

Grouped by mortality:

Expand All @@ -128,7 +134,7 @@ Grouped by mortality:
| mortality | 0 | 0 | 864 (100.0) | |
| | 1 | | | 136 (100.0) |

9. 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:
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')
Expand Down
6 changes: 5 additions & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ Example

categorical = ['ascites','hepato','edema','sex','spiders','trt']

#. Optionally, a list of columns containing continuous variables::

continuous = ['age','bili','albumin','ast','platelet','protime']

#. Optionally, a categorical variable for stratification and a list of non-normal variables::

groupby = 'trt'
nonnormal = ['bili']

#. Create an instance of TableOne with the input arguments::

mytable = TableOne(data, columns, categorical, groupby, nonnormal)
mytable = TableOne(data, columns, categorical, continuous, groupby, nonnormal)

#. 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".::

Expand Down
Loading
Loading