lifelines
Survival analysis in Python, including Kaplan Meier, Nelson Aalen and regression
What it is and what it does
lifelines is a pure Python library for survival analysis—a statistical discipline originally developed in medicine and actuarial science to answer when and why events occur under uncertainty. It provides implementations of classical estimators (Kaplan-Meier, Nelson-Aalen) and regression models to analyze time-to-event data, where observations may be censored (incomplete). The library depends on numpy, scipy, pandas, matplotlib, autograd, autograd-gamma, and formulaic to handle numerical computation, data manipulation, visualization, and automatic differentiation.
Beyond medical applications, survival analysis applies to subscriber lifetime measurement in SaaS, inventory stock-outs, political party or relationship lifespans, and A/B testing for time-to-action. lifelines abstracts the mathematical complexity, allowing researchers and data scientists to fit models, estimate survival curves, and test hypotheses on censored data without implementing the algorithms from scratch.
Use it for:
- Estimate patient survival curves and test whether treatment groups differ in time-to-event outcomes.
- Measure SaaS subscriber lifetime and identify factors (pricing, features, cohort) that influence churn.
- Analyze A/B test results to determine which variant leads to faster user action completion.
- Study political party or relationship lifespans to understand what factors predict dissolution.
- Quantify inventory demand by treating stock-outs as censoring events in demand estimation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
lifelines implements survival analysis methods—Kaplan-Meier, Nelson-Aalen, and regression models—to estimate time-to-event distributions and identify factors influencing when events occur.
Yes. lifelines is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. It is the standard Python library for survival analysis and well-suited for anyone analyzing time-to-event data with censoring. Install it if you need to fit survival models or estimate event-time distributions.
Install
lifelines on PyPI
pip
pip install lifelinesuv
uv add lifelinespoetry
poetry add lifelinesInstalling lifelines
Before you install
Low friction: pure Python wheel, active maintenance (last commit 2026-03-07), and modern Python support (3.11+). Seven runtime dependencies are all standard scientific packages (numpy, scipy, pandas, matplotlib, autograd, autograd-gamma, formulaic), widely available and well-maintained.
License in practice
MIT license is permissive; you can use, modify, and distribute lifelines with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install lifelines
from lifelines import KaplanMeierFitter
import pandas as pd
kmf = KaplanMeierFitter()
kmf.fit(durations=df['time'], event_observed=df['event'])
kmf.plot_survival_function()
Requires Python 3.11 or later.
Verify before relying
- Whether the package supports right-censored, left-censored, and interval-censored data types beyond what the description implies.
- Performance characteristics and scalability limits for large datasets or high-dimensional covariate spaces.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — numpy, scipy, pandas, matplotlib, autograd, autograd-gamma, formulaic |
| Maintenance | actively maintained — 162 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,547,917/month — #3,006 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: lifelines-0.30.3-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
LifetimesLifetimes models customer behavior and predicts…
permissive · top 15,000 on PyPI
reliabilityReliability engineering and survival analysis…
copyleft · top 5,000 on PyPI
scikit-survivalscikit-survival provides survival analysis…
copyleft · top 15,000 on PyPI
statsmodelsstatsmodels provides statistical models,…
permissive · top 1,000 on PyPI
pymannkendallImplements a suite of Mann-Kendall trend tests…
permissive · top 15,000 on PyPI
pytensor-distributionsPyTensor-distributions provides a collection of…
permissive · top 15,000 on PyPI
linearmodelsProvides panel regression, instrumental…
unclear · top 15,000 on PyPI
yellowbrickYellowbrick provides scikit-learn-integrated…
permissive · top 15,000 on PyPI
spregspreg estimates simultaneous autoregressive…
permissive · top 15,000 on PyPI
conda-packconda-pack creates relocatable conda…
permissive · top 15,000 on PyPI