.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/tableone/plot_main02.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_tableone_plot_main02.py: 02. Basic example ----------------- Basic usage of the tableone library. .. GENERATED FROM PYTHON SOURCE LINES 7-37 .. code-block:: default :lineno-start: 7 # Libraries import pandas as pd # Specific from pathlib import Path from tableone import TableOne # ------------------------ # Load data # ------------------------ # Load data path = Path('../../datasets/dengue-htd-dataset') data = pd.read_csv(path / 'dengue.csv') # ------------------------ # Create tableone # ------------------------ # Columns columns = ['age', 'gender', 'haematocrit_percent', 'plt'] # Categorical categorical = ['gender'] # Groupby groupby = ['cvs_hos_split'] # mytable = TableOne(data, columns, categorical, groupby) .. GENERATED FROM PYTHON SOURCE LINES 38-40 Show .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: default :lineno-start: 41 mytable.tableone .. raw:: html
Grouped by cvs_hos_split
Missing Overall cvs hos
n 525 393 132
age, mean (SD) 0 37.3 (16.3) 37.4 (16.3) 36.9 (16.5)
gender, n (%) 0 0 249 (47.4) 190 (48.3) 59 (44.7)
1 276 (52.6) 203 (51.7) 73 (55.3)
haematocrit_percent, mean (SD) 0 38.5 (8.6) 38.2 (8.6) 39.3 (8.7)
plt, mean (SD) 0 106.5 (132.5) 110.8 (146.6) 93.8 (75.9)


.. GENERATED FROM PYTHON SOURCE LINES 44-47 Show (HTML) Html .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: default :lineno-start: 47 html = mytable.to_html() # show print(html) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
Grouped by cvs_hos_split
Missing Overall cvs hos
n 525 393 132
age, mean (SD) 0 37.3 (16.3) 37.4 (16.3) 36.9 (16.5)
gender, n (%) 0 0 249 (47.4) 190 (48.3) 59 (44.7)
1 276 (52.6) 203 (51.7) 73 (55.3)
haematocrit_percent, mean (SD) 0 38.5 (8.6) 38.2 (8.6) 39.3 (8.7)
plt, mean (SD) 0 106.5 (132.5) 110.8 (146.6) 93.8 (75.9)
.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.133 seconds) .. _sphx_glr_download__examples_tableone_plot_main02.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_main02.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_main02.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_