Skip to main content

SNU_DHC Package

Project description

SNU-DHC

Description

DemoTable generates baseline characteristic tables for medical studies and exports them to Excel. It supports continuous and categorical variables, grouping, and automatic p-value calculation.

Parameters:

  • df: Input pandas DataFrame.
  • table_name: Title for the Excel sheet.
  • variables: List of dictionaries defining the variables to display.
  • group_variable: Optional column to group comparisons.
  • group_labels: Display labels for group values.
  • show_total: Whether to show the total column.
  • show_missing: Whether to show missing counts for categorical variables.
  • percent_decimals: Decimal places for percentages.
  • thousands_sep: Use comma separator for each thousand numbers.
  • show_p_values: Whether to include a p-value column.
  • p_value_decimals: Fixed or automatic formatting for p-values.

Test selection logic (for p-values):

  • Continuous (mean):
    • 2 groups: Welch's t-test (with checks and warnings for normality)
    • 3+ groups: ANOVA (with checks and warnings for normality and variance)
  • Continuous (median):
    • 2 groups: Mann-Whitney U test
    • 3+ groups: Kruskal-Wallis test
  • Categorical:
    • Chi-square test by default
    • Fisher's exact test if 2x2 and <5 cell counts

Usage Example

from snu_dhc.tables import DemoTable
    
variables_config = [
    {"var": "age", "name": "Age", "type": "continuous", "stat": "median", "decimals": 0},
    {"var": "sex", "name": "Sex", "type": "categorical", "class_labels": {1: "Male", 0: "Female"}},
    {"var": "dm", "name": "Diabetes mellitus", "type": "categorical", "class_labels": {1: ""}},
    {"var": "init_rhythm", "name": "Initial rhythm", "type": "categorical", "class_labels": {1: "VF/VT", 2: "PEA", 3: "Asystole"}},
    {"var": "rti", "name": "RTI", "type": "continuous", "stat": "median", "decimals": 0},
]

table = DemoTable(
    df=ohca_group,
    table_name="Table 1. Baseline characteristics of study patients",
    variables=variables_config,
    group_variable="group",
    group_labels={"train": "Train", "val": "Validation", "test": "Test"}, 
    show_total=True,
    show_missing=True,
    percent_decimals=1,
    thousands_sep=True,
    show_p_values=True,
    p_value_decimals="auto"
)

table.save("table1.xlsx")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snu_dhc-0.1.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snu_dhc-0.1.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file snu_dhc-0.1.4.tar.gz.

File metadata

  • Download URL: snu_dhc-0.1.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for snu_dhc-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8b62049e261602bdac124229a74ffa2af3932195ffff9e579d038aef091d1a76
MD5 4ee771725f0fac83454d3349207a08b7
BLAKE2b-256 309d1377003395c18009aa30dd05f1425310920836d2714cb96d36ba83c571a5

See more details on using hashes here.

File details

Details for the file snu_dhc-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: snu_dhc-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for snu_dhc-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 82bcf97710cfb173dba22ccdb521bf590595840d5eea51bb2ee7253a6483a2d6
MD5 e7a3026aac712f6acf07a263b29642f2
BLAKE2b-256 816992b93fc21a5977377e60732d600e742e414ce63db5bf0b5e1d50663878f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page