skillfed

lifelines

Survival analysis in Python, including Kaplan Meier, Nelson Aalen and regression

lifelines v0.30.3 2.5M downloads/30d#3,006 on PyPI2,604
Permissive license MIT Active released

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 lifelines

uv

uv add lifelines

poetry

poetry add lifelines

Installing 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

Development Status :: 4 - BetaLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering

Tags

survival analysis pythonkaplan meier estimatortime to event analysiscensored data analysisnelson aalen estimatorcox regressionlifetime analysis
survival-analysistime-to-eventstatistical-modeling

More Scientific/Engineering packages