patsy
A Python package for describing statistical models and for building design matrices.
Decision gist · record as of 2026-08-14
Yes, with conditions. Patsy is stable, well-maintained for compatibility, and has no known vulnerabilities. Install it if you need R-style formula notation for design matrices or are porting R code. However, the maintainers explicitly recommend Formulaic for new projects, so evaluate whether starting with Formulaic would better suit your long-term needs despite patsy's current stability.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.6 or later; scipy is optional but needed for spline functions like bs().
- Low friction: pure-Python wheel with only numpy as a runtime dependency.
- Actively maintained as of August 2026, though the project is in maintenance mode with no new feature development planned.
License · maintenance · safety
2-clause BSD (permissive) — 2-clause BSD is permissive; you can use, modify, and distribute patsy with minimal restrictions, provided you retain the license notice.
last release 2025-10-20 (298 days) · last repo commit 2026-08-10 · 989 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 38,737,083 downloads/mo, #708 on PyPI
Alternatives
Verify before relying
pip install patsy
import patsy
import numpy as np
y = np.array([1, 2, 3])
x = np.array([0, 1, 2])
design_info = patsy.design_matrix_builders(
'y ~ x',
{'y': y, 'x': x}
)- Whether the maintenance-mode status affects long-term compatibility with future Python releases beyond 3.13.
- Performance characteristics when handling large design matrices or complex formula expressions.
- Whether Formulaic is a suitable replacement for your specific use case.
What it is and what it does
Patsy is a statistical modeling library that brings R's formula notation to Python, allowing you to specify linear models and design matrices using human-readable formulas instead of manually constructing numpy arrays. It parses formulas and builds the corresponding design matrices, handling categorical variables, interactions, and transformations automatically. The package is mature and widely used in the scientific Python ecosystem, but as of August 2021 it entered maintenance mode—the maintainers recommend migrating to Formulaic for new projects, though they continue to keep patsy compatible with current Python releases.
Patsy depends only on numpy at runtime, making it lightweight and easy to integrate. It supports Python 3.6 through 3.13 and carries a permissive 2-clause BSD license. Optional scipy support enables spline-related functions. The library is particularly valuable when you need to express statistical models declaratively or when porting R code to Python.
Use it for
- Build design matrices from R-style formulas for use with regression libraries.
- Specify categorical variables and interactions in linear models without manual encoding.
- Port statistical modeling code from R to Python while preserving formula syntax.
- Construct model specifications with transformations for statistical analysis.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Patsy is stable, well-maintained for compatibility, and has no known vulnerabilities. Install it if you need R-style formula notation for design matrices or are porting R code. However, the maintainers explicitly recommend Formulaic for new projects, so evaluate whether starting with Formulaic would better suit your long-term needs despite patsy's current stability.
Install
patsy on PyPI
Before you install
Low friction: pure-Python wheel with only numpy as a runtime dependency. Actively maintained as of August 2026, though the project is in maintenance mode with no new feature development planned.
Requires Python 3.6 or later; scipy is optional but needed for spline functions like bs().
License in practice
2-clause BSD is permissive; you can use, modify, and distribute patsy with minimal restrictions, provided you retain the license notice.
Quickstart
pip install patsy
import patsy
import numpy as np
y = np.array([1, 2, 3])
x = np.array([0, 1, 2])
design_info = patsy.design_matrix_builders(
'y ~ x',
{'y': y, 'x': x}
)
Verify before relying
- Whether the maintenance-mode status affects long-term compatibility with future Python releases beyond 3.13.
- Performance characteristics when handling large design matrices or complex formula expressions.
- Whether Formulaic is a suitable replacement for your specific use case.
Package facts
| License | 2-clause BSD permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagenumpy |
| Maintenance | Actively maintained 298 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 38,737,083 / month, #708 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 6 - MatureIntended Audience :: DevelopersIntended Audience :: Financial and Insurance IndustryIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering |
Evidence: patsy-1.0.2-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “R formula syntax for Python”
- patsyPatsy converts R-style statistical formulas into design matrices for…
- formulasParses and compiles Excel formulas and workbooks into executable…
- formulaicFormulaic converts tabular data into model matrices using Wilkinson…
Give your agent the search over MCP, or paste the wish link into any chat.
More Scientific/Engineering packages
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
pandas provides fast, flexible data structures (Series and DataFrame) for loading, cleaning, transforming, and analyzing labeled or relational data in Python.
scipy provides numerical algorithms for mathematics, science, and engineering—including optimization, integration, linear algebra, Fourier transforms, signal and image processing, and ODE solvers—built on numpy arrays.
scikit-learn provides a comprehensive Python library for supervised and unsupervised machine learning, including classification, regression, clustering, dimensionality reduction, and model evaluation tools built on NumPy and SciPy.
Install it if you need to train, evaluate, or deploy supervised or unsupervised learning models.
dill extends Python's pickle module to serialize and deserialize a much wider range of Python objects, including functions, lambdas, classes, and interpreter sessions, to byte streams for storage or network transmission.
Multiprocess is an enhanced fork of Python's standard multiprocessing library that uses dill for better serialization, allowing you to spawn processes with a threading-like API and share complex objects between them.
Install it if you use multiprocessing and encounter pickle serialization limits with lambdas or complex objects.
See also formulaic · formulaic-contrasts · formulas · linearmodels · statsmodels · spglm · scikit-fem · tabmat · xlcalculator · polars-ols