Patsy is a Python package for describing statistical models and for building design matrices, bringing R-style formulas to Python. The current version is 1.0.2. While no new feature development is planned, it maintains a maintenance cadence to ensure compatibility with current releases in the Python ecosystem.
Install & Compatibility
Where this runs
tested against v1.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.925 runs
installs and imports cleanly · install 0.0s · import 0.274s · 90.8MB
glibcpy 3.10–3.925 runs
installs and imports cleanly · install 3.7s · import 0.271s · 87MB
90MB installed
● package 90MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from patsy import dmatrix
from patsy import dmatrices
A utility function for quick examples and testing.
from patsy import demo_data
This quickstart demonstrates how to use `patsy.dmatrices` to generate design matrices from a formula string and a dictionary-like data source. It automatically handles categorical variables and adds an intercept term.
import numpy as np
from patsy import dmatrices, demo_data
# Create example data
data = demo_data("a", "b", "x1", "x2", "y")
# Generate design matrices for a linear model
y, X = dmatrices("y ~ x1 + x2 + a", data=data)
print("Dependent variable (y):")
print(y)
print("\nIndependent variables (X):")
print(X)
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.