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 large 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 and variance)
- 3+ groups: ANOVA (with similar warnings)
- 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 low cell counts
- Fall back to chi-square with warning otherwise
Usage Example
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
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
snu_dhc-0.1.2.tar.gz
(7.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snu_dhc-0.1.2.tar.gz.
File metadata
- Download URL: snu_dhc-0.1.2.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211ca790fa7429978f3a24f65686fee61c3406b7f65dacebc48f4f478e242ce3
|
|
| MD5 |
61e71518f7f56238cab1619cc462eb03
|
|
| BLAKE2b-256 |
c1046cc7891624c1a113ea2b84ea9dd015419649b6f188b1817afa4d9f711841
|
File details
Details for the file snu_dhc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: snu_dhc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02b4abc75505169bacf6fa0c445b36b89dc62ad961a19d60f53715d04e763312
|
|
| MD5 |
72b5ce423247b5a0b7e09180b4b3b5c7
|
|
| BLAKE2b-256 |
d34fb66b9f937c219a3d92c444147837d217bbdd5f8dc4f35cc0d29002aa1ff8
|