Python statistics libraries

Updated Nov 2026

Python statistics libraries compute descriptive statistics, run hypothesis tests, and fit statistical models to data. Some libraries specialize in one family of models, such as survival analysis, Bayesian inference, or time series forecasting. These libraries let analysts, researchers, and AI agents test hypotheses and fit models in Python.

Popularity

SciPy has the most monthly downloads in this comparison, at 389.6M, a count that covers all its scientific computing.

LibraryMonthly downloadsStarsLast releaseLicense
SciPy
389.6M
15.2KAug 2026BSD-3-Clause
statsmodels
40.4M
11.8KAug 2026BSD-3-Clause
CmdStanPy
4.3M
198Nov 2026BSD-3-Clause
Prophet
4.1M
20.5KOct 2026MIT
ArviZ
2.7M
1.9KAug 2026Apache-2.0
lifelines
2.2M
2.6KMar 2026MIT
StatsForecast
1.8M
5.0KJul 2026Apache-2.0
pmdarima
1.7M
1.7KNov 2025MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryNUTS samplerCox PH regressionForecasting API
SciPyUnsupportedUnsupportedUnsupported
statsmodelsUnsupportedBuilt-inBuilt-in
CmdStanPyBuilt-inUnsupportedUnsupported
ProphetBuilt-inUnsupportedBuilt-in
ArviZUnsupportedUnsupportedUnsupported
lifelinesUnsupportedBuilt-inUnsupported
StatsForecastUnsupportedUnsupportedBuilt-in
pmdarimaUnsupportedUnsupportedBuilt-in
Built-inNot supported

Libraries and code examples

Provides statistical tests, probability distributions, and numerical routines.

Downloads / mo
389.6M
Stars
15.2K
Last release
1.18.1
License
BSD-3-Clause

Strengths

  • Covers tests and distributions. Use distributions, correlations, and hypothesis tests from the same package.
  • Controls false discovery rates. Adjust p-values with false_discovery_control().

Limitations

  • ttest_ind assumes equal variances. Set equal_var=False to compare groups with unequal variances.
  • Missing values propagate by default. Choose a nan_policy when inputs contain missing values.
$ pip install scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng()
rvs1 = stats.norm.rvs(loc=5, scale=10, size=500, random_state=rng)
rvs2 = stats.norm.rvs(loc=5, scale=10, size=500, random_state=rng)
stats.ttest_ind(rvs1, rvs2)

SciPy examples

From open-source projects on GitHub

Estimates statistical models and runs hypothesis tests.

Downloads / mo
40.4M
Stars
11.8K
Last release
0.15.0
License
BSD-3-Clause

Strengths

  • Accepts R-style model formulas. Describe models with formulas against pandas DataFrames.
  • Fits Bayesian mixed-effects models. Estimate binomial and Poisson mixed models with Bayesian approximation methods.

Limitations

  • Missing data needs explicit handling. Set missing='raise' or clean missing values before fitting.
  • Array OLS omits automatic intercepts. Call add_constant when the model needs an intercept.

Quickstart

From index.html
$ pip install statsmodels
import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf
# Load data
dat = sm.datasets.get_rdataset("Guerry", "HistData").data
# Fit regression model (using the natural log of one of the regressors)
results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=dat).fit()
# Inspect the results
print(results.summary())

statsmodels examples

From open-source projects on GitHub

Provides a Python interface to CmdStan.

Downloads / mo
4.3M
Stars
198
Last release
1.3.2
License
BSD-3-Clause

Quickstart

From README.md
$ pip install cmdstanpy
import os
from cmdstanpy import cmdstan_path, CmdStanModel

# specify locations of Stan program file and data
stan_file = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
data_file = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.data.json')

# instantiate a model; compiles the Stan program by default
model = CmdStanModel(stan_file=stan_file)

# obtain a posterior sample from the model conditioned on the data
fit = model.sample(chains=4, data=data_file)

CmdStanPy examples

From open-source projects on GitHub

Runs an automatic forecasting procedure.

Downloads / mo
4.1M
Stars
20.5K
Last release
1.5.0
License
MIT

Quickstart

From quick_start.html
$ pip install prophet
# Python
import pandas as pd
from prophet import Prophet

# Python
df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv')
df.head()

# Python
m = Prophet()
m.fit(df)

Prophet examples

From open-source projects on GitHub

Exposes ArviZ features in one namespace.

Downloads / mo
2.7M
Stars
1.9K
Last release
1.3.0
License
Apache-2.0

Quickstart

From visualization.py
$ pip install arviz
import arviz as az
import numpy as np

data = np.random.default_rng().normal(size=2000)
az.hdi(data, 0.68)

ArviZ examples

From open-source projects on GitHub
def _create_get_hdi_plot_data(hdi_kwargs) -> GetPlotData:
    def get_plot_data(data: xr.DataArray) -> xr.DataArray:
        hdi = az.hdi(data, **hdi_kwargs)
        if isinstance(hdi, xr.Dataset) and data.name is not None:
            return hdi[data.name]
        return hdi  # DataArray case

    return get_plot_data

Runs survival analysis, including Kaplan-Meier, Nelson-Aalen, and regression models.

Downloads / mo
2.2M
Stars
2.6K
Last release
0.30.3
License
MIT

Quickstart

From Quickstart.html
$ pip install lifelines
from lifelines.datasets import load_waltons
df = load_waltons() # returns a Pandas DataFrame

T = df['T']
E = df['E']

from lifelines import KaplanMeierFitter
kmf = KaplanMeierFitter()
kmf.fit(T, event_observed=E)  # or, more succinctly, kmf.fit(T, E)

lifelines examples

From open-source projects on GitHub

Forecasts time series with statistical models.

Downloads / mo
1.8M
Stars
5.0K
Last release
2.1.1
License
Apache-2.0

Quickstart

From README.md
$ pip install statsforecast
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA
from statsforecast.utils import AirPassengersDF

df = AirPassengersDF
sf = StatsForecast(
    models=[AutoARIMA(season_length=12)],
    freq='ME',
)
sf.fit(df)
sf.predict(h=12, level=[95])

StatsForecast examples

From open-source projects on GitHub

Selects ARIMA models automatically, like the forecast package's auto.arima.

Downloads / mo
1.7M
Stars
1.7K
Last release
2.1.1
License
MIT

Quickstart

From README.md
$ pip install pmdarima
import pmdarima as pm
from pmdarima.model_selection import train_test_split

# Load/split your data
y = pm.datasets.load_wineind()
train, test = train_test_split(y, train_size=150)

# Fit your model
model = pm.auto_arima(train, seasonal=True, m=12)

pmdarima examples

From open-source projects on GitHub

FAQ

SciPy suits probability distributions, correlations, and statistical tests. statsmodels suits regression, time series, and survival models with inference. lifelines suits survival analysis. Prophet suits forecasts with trend and seasonality.

statsmodels estimates statistical models and runs hypothesis tests, with formula-based regression workflows. Its array-based OLS interface leaves the intercept out by default.

StatsForecast is a time series forecasting suite of statistical models, with automatic ARIMA and ETS model selection.

SciPy covers probability distributions, correlations, and statistical tests. statsmodels adds model estimation and formula-based regression.

Prophet forecasts time series with trend and seasonality components. Its default fit is a point estimate, with optional full Bayesian sampling through Stan.

For coding agents

Found your statistics library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official