Python package to calculate comorbidity scores and other clinical risk scores.
Project description
comorbidipy
A high-performance Python package for calculating comorbidity scores and clinical risk scores from ICD codes.
Built with Polars for blazing-fast processing of large datasets.
Features
- Charlson Comorbidity Index – Multiple mapping variants (Quan, Swedish, Australian, SHMI) and weighting schemes
- Elixhauser Comorbidity Index – Quan mapping with van Walraven or Swiss weights
- Hospital Frailty Risk Score (HFRS) – For patients ≥75 years
- Disability & Sensory Impairments – Learning disabilities, visual and hearing impairments
Installation
pip install comorbidipy
Requires Python 3.13+.
Quick Start
Python API
import polars as pl
from comorbidipy import comorbidity, hfrs, disability
# Sample data
df = pl.DataFrame({
"id": ["P001", "P001", "P002", "P002"],
"code": ["I21", "E112", "I50", "J44"],
"age": [65, 65, 72, 72],
})
# Calculate Charlson Comorbidity Index
result = comorbidity(df, id_col="id", code_col="code", age_col="age")
# Calculate Hospital Frailty Risk Score
frailty = hfrs(df, id_col="id", code_col="code")
# Identify disabilities
disabilities = disability(df, id_col="id", code_col="code")
Command Line Interface
# Charlson score
comorbidipy charlson input.csv output.csv --age-col age
# Elixhauser score
comorbidipy elixhauser input.parquet output.parquet --weights van_walraven
# Hospital Frailty Risk Score
comorbidipy hfrs input.csv output.csv
# Disability identification
comorbidipy disability input.csv output.csv
# Show available options
comorbidipy info
Supported file formats: CSV, Parquet, JSON, NDJSON, Avro.
Charlson Variants
| Mapping | ICD-9 | ICD-10 | Description |
|---|---|---|---|
quan |
✅ | ✅ | Quan et al. (2005) |
swedish |
❌ | ✅ | Swedish National Patient Register |
australian |
❌ | ✅ | Australian IHW adaptation |
shmi |
❌ | ✅ | UK SHMI specification |
| Weighting | Description |
|---|---|
charlson |
Original 1987 weights |
quan |
Quan et al. updated weights |
shmi |
UK SHMI weights |
shmi_modified |
Modified SHMI weights |
Documentation
Full documentation: https://vvcb.github.io/comorbidipy
License
MIT License – see LICENSE for details.
Credits
- Inspired by the R library
comorbidityby Alessandro Gasparini - Built with Polars and Typer
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
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 comorbidipy-0.8.0.tar.gz.
File metadata
- Download URL: comorbidipy-0.8.0.tar.gz
- Upload date:
- Size: 103.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
759cc321ae4eec7a3c0637661fbf541447e5be176b8adc2c29b2a45436c744dc
|
|
| MD5 |
05ae2340dd1e12a04922d4cc3b0a1905
|
|
| BLAKE2b-256 |
4a1f05b24e28b266bea5acc55c436bc7d669439d31f1f4a9241603f6a4ffd43a
|
File details
Details for the file comorbidipy-0.8.0-py3-none-any.whl.
File metadata
- Download URL: comorbidipy-0.8.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac280f660ff934c2cd8538896ce6be2f55c5e45a181e7f60c4906c2d7da5ed89
|
|
| MD5 |
874a4d7c463b709b0352da2ed78fb631
|
|
| BLAKE2b-256 |
8aeebc7bcd4c27b9aba636355b67101a15eeb02e3335bb1ea62e78d429f0e23c
|