Skip to main content

Look up ICD codes and map them to descriptions. Supports ICD-10 (extensible to other versions).

Project description

icdlookup

A Python package for looking up ICD codes and mapping them to human-readable descriptions.

Ships with a built-in ICD-10-CM 2026 dataset sourced from the official CMS ICD-10 files. The hierarchy approach was inspired by rjake/ICD10-hierarchy.

The package name is version-agnostic — future releases may extend support to ICD-9, ICD-11, and other coding systems.

Installation

pip install icdlookup

For DataFrame annotation support:

pip install icdlookup[pandas]

Quick Start

Look up a single code

import icdlookup

icdlookup.lookup("A00.1")
# → "cholera due to vibrio cholerae 01, biovar eltor"

Get full hierarchy detail

icdlookup.lookup("A00.1", detail=True)
# → {
#     "icd10_code": "A00.1",
#     "description": "cholera due to vibrio cholerae 01, biovar eltor",
#     "chapter_desc": "Certain infectious and parasitic diseases (A00-B99)",
#     "section_desc": "Intestinal infectious diseases (A00-A09)",
#     "category_desc": "cholera"
#   }

Search by keyword

icdlookup.search("cholera")
# → [("A00", "cholera"), ("A00.0", "cholera due to ..."), ...]

Annotate a pandas DataFrame

import pandas as pd
import icdlookup

df = pd.DataFrame({"icd_code": ["A00.1", "J06.9", "E11.9"]})
df = icdlookup.annotate(df, code_column="icd_code")
# df now has an "icd_description" column

Use a custom reference CSV

Any CSV with at least icd10_code and description columns works:

icdlookup.lookup("A00.1", reference="/path/to/custom.csv")
icdlookup.annotate(df, code_column="icd_code", reference="/path/to/custom.csv")

CLI

# Single lookup
icdlookup A00.1

# Full detail
icdlookup A00.1 --detail

# Search by keyword
icdlookup --search cholera

# Annotate a CSV file
icdlookup --file data.csv --column icd_code --output annotated.csv

# Use custom reference
icdlookup A00.1 --reference /path/to/custom.csv

Design

  • No pandas required for core functionslookup() and search() use only the standard library (csv + gzip). pandas is only needed for annotate().
  • Case & format insensitive — lookups strip whitespace, are case-insensitive, and work with or without dots (A001 and A00.1 both match).
  • Lazy-loaded & cached — the built-in CSV is only parsed on first use, then kept in memory for the session.
  • Custom reference support — pass any CSV with icd10_code + description columns.
  • 48,600+ ICD-10-CM codes — the bundled 2026 dataset includes full hierarchy info (chapter, section, category descriptions).

Data Source

The bundled dataset is derived from the official CMS ICD-10-CM 2026 Code Tables, specifically the tabular XML file. Each code includes:

Column Description
icd10_code The ICD-10-CM code (e.g. A00.1)
description Human-readable description
chapter_desc Chapter-level description
section_desc Section-level description
category_desc 3-character category description

Rebuilding the Dataset

To regenerate the bundled data from the latest CMS release:

python scripts/build_data.py

This downloads the CMS XML zip, parses the hierarchy, and writes the compressed CSV to src/icdlookup/_data/.

Development

git clone https://github.com/icdlookup/icdlookup.git
cd icdlookup
pip install -e ".[dev]"
pytest

License

MIT

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

icdlookup-0.1.0.tar.gz (469.7 kB view details)

Uploaded Source

Built Distribution

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

icdlookup-0.1.0-py3-none-any.whl (462.1 kB view details)

Uploaded Python 3

File details

Details for the file icdlookup-0.1.0.tar.gz.

File metadata

  • Download URL: icdlookup-0.1.0.tar.gz
  • Upload date:
  • Size: 469.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for icdlookup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f851ab73fc1d1980b4d2f576c509bca04d4dd8914898b66d1aa1c58064ad9e96
MD5 1654706223a03e8a1233eebb1273923f
BLAKE2b-256 896bb594f9b6ca82b9a98fc4959b4c1658297118030079be3f3e604ad6e3aac0

See more details on using hashes here.

Provenance

The following attestation bundles were made for icdlookup-0.1.0.tar.gz:

Publisher: publish.yml on yabdulle/icdlookup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file icdlookup-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: icdlookup-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 462.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for icdlookup-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc89cf90f72634258849c727e671aad55d8811792df9185ddfb061e925f7c1c4
MD5 12d3453380a48ecd0d61c84e4da6fa77
BLAKE2b-256 bf900c1fc15a94f190b617c1ef372300e8f3d364a0c3761760a33ee9cb554548

See more details on using hashes here.

Provenance

The following attestation bundles were made for icdlookup-0.1.0-py3-none-any.whl:

Publisher: publish.yml on yabdulle/icdlookup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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