dowhy
DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions
What it is and what it does
DoWhy is a causal inference library that helps you move beyond predictive modeling to understand cause-and-effect relationships in your data. It combines two major frameworks—graphical causal models and potential outcomes—to provide a unified interface for answering causal questions: identifying whether a causal effect is estimable from your data, computing average or conditional treatment effects, performing mediation analysis, and attributing observed outcomes to their causes.
The library supports effect estimation (using instrumental variables, propensity score methods, and other techniques), root cause analysis (finding what caused an anomaly or change in distribution), what-if simulation (generating counterfactual samples), and refutation testing (validating whether your causal assumptions hold). It's designed for practitioners who need to move beyond correlation and make decisions based on causal reasoning, with built-in diagnostics to test assumptions and make inference more robust.
Use it for:
- Estimate the causal effect of a business intervention (e.g., loyalty program, pricing change) on customer behavior or revenue.
- Diagnose root causes of system failures or performance degradation in production environments.
- Quantify the direct vs. indirect effects of a treatment using mediation analysis.
- Generate counterfactual predictions to answer 'what would have happened if' scenarios for decision support.
- Validate causal assumptions and refute alternative explanations for observed effects in observational data.
- Attribute anomalies or changes in metrics to specific variables in complex systems.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
DoWhy is a Python library for causal inference that identifies and estimates causal effects, performs root cause analysis, and answers what-if questions using graphical causal models and potential outcomes frameworks.
Yes. DoWhy is actively maintained, well-documented, has no known vulnerabilities, and is backed by a strong community. Install it if you work with observational data and need to move beyond correlation to causal reasoning—whether for effect estimation, root cause analysis, or counterfactual reasoning. The permissive MIT license removes legal friction. The main consideration is the substantial dependency footprint (13 runtime packages), which is typical for scientific Python but worth checking if you're in a constrained environment.
Install
dowhy on PyPI
pip
pip install dowhyuv
uv add dowhypoetry
poetry add dowhyInstalling dowhy
Before you install
Installation is straightforward with low friction; the package is actively maintained with recent releases and a large community (8265 GitHub stars). It requires 13 runtime dependencies including scientific computing staples like numpy, pandas, and scikit-learn, which are typically already present in data science environments.
License in practice
MIT license is permissive, allowing commercial and private use without restriction, making this suitable for most professional and academic projects.
Quickstart
pip install dowhy
from dowhy import CausalModel
import pandas as pd
# Define causal graph and data
model = CausalModel(
data=df,
treatment='treatment_var',
outcome='outcome_var',
common_causes=['confounder1', 'confounder2'],
instruments=['instrument_var']
)
# Identify and estimate causal effect
identified_estimand = model.identify_effect()
estimate = model.estimate_effect(identified_estimand)
Requires Python 3.9 or later; graphviz and pygraphviz are optional but recommended for visualization of causal graphs.
Verify before relying
- Whether the package's 13 runtime dependencies can be installed without compilation issues on all target platforms.
- Performance characteristics when working with large datasets or complex causal graphs.
- Maturity level of specific estimation methods (library is marked Beta in classifiers).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<3.14,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 13 — causal-learn, cvxpy, cython, joblib, networkx, numba, numpy, pandas, scikit-learn, scipy, statsmodels, sympy, tqdm |
| Maintenance | actively maintained — 279 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 264,450/month — #8,339 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dowhy-0.14-py3-none-any.whl
Keywords: causality, machine-learning, causal-inference, statistics, graphical-model
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
causallibCausallib estimates causal effects from…
permissive · top 5,000 on PyPI
causalmlCausalml estimates the causal impact of…
permissive · top 15,000 on PyPI
pgmpypgmpy provides data structures and algorithms…
unclear · top 5,000 on PyPI
cemImplements Coarsened Exact Matching (CEM), a…
unclear · top 5,000 on PyPI
econmlEconML estimates heterogeneous treatment…
permissive · top 15,000 on PyPI
rdrobustImplements regression discontinuity (RD) design…
copyleft · top 15,000 on PyPI
pyfixestPyFixest performs fast high-dimensional fixed…
permissive · top 15,000 on PyPI
psmpyPsmPy implements propensity score matching for…
permissive · top 5,000 on PyPI